當前位置: 首頁>>代碼示例>>Python>>正文


Python Edge.get_subclasses方法代碼示例

本文整理匯總了Python中edge.Edge.get_subclasses方法的典型用法代碼示例。如果您正苦於以下問題:Python Edge.get_subclasses方法的具體用法?Python Edge.get_subclasses怎麽用?Python Edge.get_subclasses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edge.Edge的用法示例。


在下文中一共展示了Edge.get_subclasses方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __declare_last__

# 需要導入模塊: from edge import Edge [as 別名]
# 或者: from edge.Edge import get_subclasses [as 別名]
 def __declare_last__(cls):
     src_ids, dst_ids = [], []
     for scls in Edge.get_subclasses():
         name = scls.__name__
         name_in = '_{}_in'.format(name)
         name_out = '_{}_out'.format(name)
         src_assoc = getattr(scls, SRC_DST_ASSOC)
         dst_assoc = getattr(scls, DST_SRC_ASSOC)
         if scls.__dst_class__ == cls.__name__:
             if not hasattr(cls, name_in):
                 edge_in = relationship(
                     name,
                     foreign_keys=[scls.dst_id],
                     backref='dst',
                     cascade='all, delete, delete-orphan',
                 )
                 setattr(cls, name_in, edge_in)
                 cls._edges_in.append(name_in)
                 dst_ids.append(scls.dst_id)
             cls._set_association_proxy(scls, dst_assoc, name_in, 'src')
         if scls.__src_class__ == cls.__name__:
             if not hasattr(cls, name_out):
                 edge_out = relationship(
                     name,
                     foreign_keys=[scls.src_id],
                     backref='src',
                     cascade='all, delete, delete-orphan',
                 )
                 setattr(cls, name_out, edge_out)
                 cls._edges_out.append(name_out)
                 src_ids.append(scls.src_id)
             cls._set_association_proxy(scls, src_assoc, name_out, 'dst')
開發者ID:NCI-GDC,項目名稱:psqlgraph,代碼行數:34,代碼來源:node.py

示例2: get_edge_by_labels

# 需要導入模塊: from edge import Edge [as 別名]
# 或者: from edge.Edge import get_subclasses [as 別名]
 def get_edge_by_labels(self, src_label, edge_label, dst_label):
     src_classes = [n for n in Node.get_subclasses()
                    if n.get_label() == src_label]
     dst_classes = [n for n in Node.get_subclasses()
                    if n.get_label() == dst_label]
     assert len(src_classes) == 1,\
         'No classes found with src_label {}'.format(src_label)
     assert len(dst_classes) == 1,\
         'No classes found with dst_label {}'.format(dst_label)
     edges = [edge for edge in Edge.get_subclasses()
              if edge.__src_class__ == src_classes[0].__name__
              and edge.__dst_class__ == dst_classes[0].__name__
              and edge.get_label() == edge_label]
     assert len(edges) == 1,\
         'Expected 1 edge {}-{}->{}, found {}'.format(
             src_label, edge_label, dst_label, len(edges))
     return edges[0]
開發者ID:NCI-GDC,項目名稱:psqlgraph,代碼行數:19,代碼來源:psqlgraph.py


注:本文中的edge.Edge.get_subclasses方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。