本文整理汇总了Python中VisionEgg.recursive_base_class_finder方法的典型用法代码示例。如果您正苦于以下问题:Python VisionEgg.recursive_base_class_finder方法的具体用法?Python VisionEgg.recursive_base_class_finder怎么用?Python VisionEgg.recursive_base_class_finder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisionEgg
的用法示例。
在下文中一共展示了VisionEgg.recursive_base_class_finder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_str
# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import recursive_base_class_finder [as 别名]
def get_str(xx, const=0):
class_by_key = {}
done_parameters_and_defaults = []
classes = VisionEgg.recursive_base_class_finder(xx)
# Fill self.parameters with parameter names and set to default values
for klass in classes:
if klass == object:
continue # base class of new style classes - ignore
if const:
pd = klass.constant_parameters_and_defaults
else:
pd = klass.parameters_and_defaults
if pd not in done_parameters_and_defaults:
for parameter_name in pd.keys():
class_by_key[parameter_name] = klass
done_parameters_and_defaults.append(pd)
ks = class_by_key.keys()
ks.sort()
if len(ks):
out_strs = []
if not const:
out_strs.append("Parameters\n")
out_strs.append("==========\n")
else:
out_strs.append("Constant Parameters\n")
out_strs.append("===================\n")
# pass 1:
max_len = 0
for param_name in ks:
max_len = max(max_len, len(param_name))
for param_name in ks:
klass = class_by_key[param_name]
if const:
p = klass.constant_parameters_and_defaults
else:
p = klass.parameters_and_defaults
if len(p[param_name]) > 3:
if p[param_name][3] == VisionEgg.ParameterDefinition.DEPRECATED:
continue
type_str = param_name
default = p[param_name][0]
ve_type = p[param_name][1]
if len(p[param_name]) > 2:
description = p[param_name][2] + " "
else:
description = ""
out_strs.append("%s -- %s(%s)\n" % (param_name.ljust(max_len), description, str(ve_type)))
if xx != klass:
if klass.__module__ != xx.__module__:
mod_name = "%s." % klass.__module__
else:
mod_name = ""
out_strs.append(" " * (max_len + 4) + "Inherited from %s%s\n" % (mod_name, klass.__name__))
tmp = str(default).split("\n")
if default is None:
tmp = ["(determined at runtime)"]
if len(p[param_name]) > 3:
if p[param_name][3] == VisionEgg.ParameterDefinition.OPENGL_ENUM:
if default is None:
gl_name = "(GL enum determined at runtime)"
else:
gl_name = str(default)
tmp = [gl_name]
out_strs.append(" " * (max_len + 4) + "Default: " + tmp[0] + "\n")
if len(tmp) > 1:
for i in range(1, len(tmp)):
out_strs.append(" " * (max_len + 13) + tmp[i] + "\n")
return out_strs