本文整理汇总了Python中context.Context.add_vertex方法的典型用法代码示例。如果您正苦于以下问题:Python Context.add_vertex方法的具体用法?Python Context.add_vertex怎么用?Python Context.add_vertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.add_vertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: baseVertex
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_vertex [as 别名]
#.........这里部分代码省略.........
element = self._create_element(vertex=vertex,
**obj[self.vertex_type])
for dependant_vertex in self.dependant_vertexes:
self._add_to_context_path(element)
self.dependent_vertex_objs.append(
dependant_vertex(context=self.context, element=element))
self._remove_from_context_path(element)
def get_dependent_vertices(self):
return self.dependent_vertex_objs
def create_vertex(self, vertex_type, **kwargs):
vertex = defaultdict(dict)
vertex.update({
'vertex_type': vertex_type,
'config': {},
'agent' : defaultdict(dict),
'control': defaultdict(dict),
'analytics': {'uve':{}},
})
for k,v in kwargs.iteritems():
vertex.update({k: v})
return vertex
def get_vertex(self):
return self.vertexes
def _store_vertex(self, vertex_type, uuid, config_obj):
fq_name = config_obj[vertex_type].get('fq_name', uuid)
if isinstance(fq_name, list):
fq_name = ':'.join(fq_name)
vertex = self.create_vertex(vertex_type, uuid=uuid, fq_name=fq_name, depth=self.depth)
self.vertexes.append(vertex)
self.context.add_vertex(vertex)
return vertex
def _is_vertex_type_exists_in_path(self):
for element in self.context.get_path():
if element['type'] == self.vertex_type:
return True
return False
def _create_element(self, vertex, **kwargs):
element = {}
element['type'] = vertex['vertex_type']
element['is_non_config_type'] = self.non_config_obj
element['uuid'] = vertex['uuid']
element['depth'] = self.depth + 1
if 'fq_name' in vertex:
element['fq_name'] = vertex['fq_name']
if self.non_config_obj:
kwargs.pop('uuid', None)
kwargs.pop('fq_name', None)
for k,v in kwargs.iteritems():
element[k] = v
return element
def locate_obj(self):
input_dict = {'match_dict': {}}
if self.element != None:
object_type = self.element['type']
if self.element['is_non_config_type']:
keys = set(self.element.keys()) & set(self.schema_dict[object_type].keys())
if not keys:
print 'Didnt find the key, skipping this vertex'
print self.element.keys(), self.schema_dict[object_type].keys()