本文整理汇总了Python中store.Store.id方法的典型用法代码示例。如果您正苦于以下问题:Python Store.id方法的具体用法?Python Store.id怎么用?Python Store.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类store.Store
的用法示例。
在下文中一共展示了Store.id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _jsonstr_other
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def _jsonstr_other(self, thing):
'Do our best to make JSON out of a "normal" python object - the final "other" case'
ret = '{'
comma = ''
attrs = thing.__dict__.keys()
attrs.sort()
if Store.has_node(thing) and Store.id(thing) is not None:
ret += '"_id": %s' % str(Store.id(thing))
comma = ','
for attr in attrs:
skip = False
for prefix in self.filterprefixes:
if attr.startswith(prefix):
skip = True
continue
if skip:
continue
value = getattr(thing, attr)
if self.maxJSON > 0 and attr.startswith('JSON_') and len(value) > self.maxJSON:
continue
if self.expandJSON and attr.startswith('JSON_') and value.startswith('{'):
js = pyConfigContext(value)
if js is not None:
value = js
ret += '%s"%s":%s' % (comma, attr, self._jsonstr(value))
comma = ','
ret += '}'
return ret
示例2: members_ring_order
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def members_ring_order(self):
'Return all the Drones that are members of this ring - in ring order'
## FIXME - There's a cypher query that will return these all in one go
# START Drone=node:Drone(Drone="drone000001")
# MATCH Drone-[:RingNext_The_One_Ring*]->NextDrone
# RETURN NextDrone.designation, NextDrone
if self._insertpoint1 is None:
#print >> sys.stderr, 'NO INSERTPOINT1'
return
if Store.is_abstract(self._insertpoint1):
#print >> sys.stderr, ('YIELDING INSERTPOINT1:', self._insertpoint1
#, type(self._insertpoint1))
yield self._insertpoint1
return
startid = Store.id(self._insertpoint1)
# We can't pre-compile this, but we hopefully we won't use it much...
q = '''START Drone=node(%s)
MATCH p=Drone-[:%s*0..]->NextDrone
WHERE length(p) = 0 or Drone <> NextDrone
RETURN NextDrone''' % (startid, self.ournexttype)
query = neo4j.CypherQuery(CMAdb.cdb.db, q)
for elem in CMAdb.store.load_cypher_nodes(query, Drone):
yield elem
return
示例3: get_owned_ips
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def get_owned_ips(self):
'''Return a list of all the IP addresses that this Drone owns'''
params = {'droneid':Store.id(self)}
if CMAdb.debug:
print >> sys.stderr, ('IP owner query:\n%s\nparams %s'
% (Drone.OwnedIPsQuery_subtxt, str(params)))
return [node for node in CMAdb.store.load_cypher_nodes(Drone.OwnedIPsQuery, IPaddrNode
, params=params)]
示例4: jsonval
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def jsonval(self, jsontype):
'Construct a python object associated with a particular JSON discovery value.'
if not hasattr(self, self.HASH_PREFIX + jsontype):
#print >> sys.stderr, 'DOES NOT HAVE ATTR %s' % jsontype
#print >> sys.stderr, 'ATTRIBUTES ARE:' , str(self.keys())
return None
#print >> sys.stderr, 'LOADING', self.JSONsingleattr, \
# {'droneid': Store.id(self), 'jsonname': jsontype}
node = CMAdb.store.load_cypher_node(self.JSONsingleattr, JSONMapNode,
params={'droneid': Store.id(self),
'jsonname': jsontype}
)
#assert self.json_eq(jsontype, str(node))
return node
示例5: __str__
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [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
示例6: __str__
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [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
示例7: find_child_system_from_json
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def find_child_system_from_json(self, jsonobj):
'''Locate the child drone that goes with this JSON - or maybe it's us'''
if 'proxy' in jsonobj:
path = jsonobj['proxy']
if path == 'local/local':
return self
else:
return self
# This works - could be a bit slow if you have lots of child nodes...
q = '''MATCH (drone)<-[:parentsys*]-(child)
WHERE ID(drone) = {id} AND child.childpath = {path}
RETURN child'''
store = Store.getstore(self)
child = store.load_cypher_node(q, GraphNode.factory, {'id': store.id(self), 'path': path})
if child is None:
raise(ValueError('Child system %s from %s [%s] was not found.'
% (path, str(self), str(Store.id(self)))))
return child
示例8: __iter__
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import id [as 别名]
def __iter__(self):
'Iterate over our child JSON attribute names'
for tup in CMAdb.store.load_cypher_query(self.JSONattrnames, None,
params={'droneid': Store.id(self)}):
yield tup.key