本文整理汇总了Python中store.Store.safe_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python Store.safe_attrs方法的具体用法?Python Store.safe_attrs怎么用?Python Store.safe_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类store.Store
的用法示例。
在下文中一共展示了Store.safe_attrs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __str__
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import safe_attrs [as 别名]
def __str__(self):
'Default routine for printing CMAclass objects'
result = '%s({' % self.__class__.__name__
comma = ''
for attr in Store.safe_attrs(self):
result += '%s%s = %s'% (comma, attr, str(getattr(self, attr)))
comma = ",\n "
if Store.has_node(self):
if Store.is_abstract(self):
result += comma + 'HasNode = "abstract"'
else:
result += (comma + 'HasNode = %d' %Store.id(self))
result += "\n})"
return result
示例2: __str__
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import safe_attrs [as 别名]
def __str__(self):
"Default routine for printing GraphNodes"
result = "%s({" % self.__class__.__name__
comma = ""
for attr in Store.safe_attrs(self):
result += "%s%s = %s" % (comma, attr, str(getattr(self, attr)))
comma = ",\n "
if Store.has_node(self):
if Store.is_abstract(self):
result += comma + 'HasNode = "abstract"'
else:
result += comma + "HasNode = %d" % Store.id(self)
result += "\n})"
return result
示例3: JSON
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import safe_attrs [as 别名]
def JSON(self, includemap=None, excludemap=None):
'''Output this object according to JSON rules. We take advantage
of the fact that Neo4j restricts what kind of objects we can
have as Node properties.
'''
attrstodump = []
for attr in Store.safe_attrs(self):
if includemap is not None and attr not in includemap:
continue
if excludemap is not None and attr in excludemap:
continue
attrstodump.append(attr)
ret = '{'
comma = ''
for attr in attrstodump.sort():
ret += '%s"%s": %s' % (comma, attr, GraphNode._JSONelem(getattr(self, attr)))
comma = ','
ret += '}'
return ret