本文整理汇总了Python中properties.Properties.attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.attributes方法的具体用法?Python Properties.attributes怎么用?Python Properties.attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类properties.Properties
的用法示例。
在下文中一共展示了Properties.attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_properties
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
def print_properties(prop):
def pretty(value):
if type(value) == int:
return str(value)
else:
return "%.2f" % value
ps = [pretty(getattr(prop, p)) for p in Properties.attributes()]
return formatString % tuple([prop.name] + ps)
示例2: export_all_properties
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
def export_all_properties(out, app, props):
data = { }
for prop in props:
for measurement in Properties.attributes():
key = (app, prop.name, measurement)
assert not data.has_key(key)
data[key] = getattr(prop, measurement)
pickle.dump(data, out)
示例3: tuple
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
import os
import sys
import pickle
from properties import Properties
formatString = '%20s\t%7s\t%7s\t%7s\t%7s\t%7s\t%7s'
header = formatString % tuple([""] + Properties.attributes())
def print_properties(prop):
def pretty(value):
if type(value) == int:
return str(value)
else:
return "%.2f" % value
ps = [pretty(getattr(prop, p)) for p in Properties.attributes()]
return formatString % tuple([prop.name] + ps)
def print_all_properties(out, props):
out.write("# ")
out.write("\n# ".join([header] + [print_properties(x) for x in props]))
out.write("\n")
def export_all_properties(out, app, props):
data = { }
for prop in props:
for measurement in Properties.attributes():
key = (app, prop.name, measurement)
assert not data.has_key(key)
data[key] = getattr(prop, measurement)