当前位置: 首页>>代码示例>>Python>>正文


Python ArchiLib.findElementByID方法代码示例

本文整理汇总了Python中al_lib.ArchiLib.ArchiLib.findElementByID方法的典型用法代码示例。如果您正苦于以下问题:Python ArchiLib.findElementByID方法的具体用法?Python ArchiLib.findElementByID怎么用?Python ArchiLib.findElementByID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在al_lib.ArchiLib.ArchiLib的用法示例。


在下文中一共展示了ArchiLib.findElementByID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cleanArchimateRelationships

# 需要导入模块: from al_lib.ArchiLib import ArchiLib [as 别名]
# 或者: from al_lib.ArchiLib.ArchiLib import findElementByID [as 别名]
def cleanArchimateRelationships(fileArchimate):

    al = ArchiLib(fileArchimate)

    al.logTypeCounts()

    n = 0
    countInvalid = 0

    for x in al.tree.getroot().iter():
        n += 1

        try:

            if ARCHI_TYPE in x.attrib and x.attrib[ARCHI_TYPE] in relations.values():
                sid = x.get(u"source")
                srcElm = al.findElementByID(sid)[0]

                tid = x.get(u"target")
                tgtElm = al.findElementByID(tid)[0]

                if srcElm is None or tgtElm is None:
                    logger.warn(u"Invalid Relationship : %s[%s]" % (x.get(u"id"), x.get(ARCHI_TYPE)))
                else:
                    logger.debug(u"Valid Relationship   : %s[%s]" % (x.get(u"id"), x.get(ARCHI_TYPE)))

            # <child xsi:type="archimate:DiagramObject" id="2be1001e" textAlignment="2" archimateElement="eedbdc28">
                # <bounds x="692" y="624" width="120" height="55"/>
                # <sourceConnection xsi:type="archimate:Connection" id="c90d2077" source="2be1001e" target="aff3d6b3" relationship="56057f65"/>
                # <sourceConnection xsi:type="archimate:Connection" id="d5cac998" source="2be1001e" target="dfa5c47b" relationship="99bc54ab"/>
                # <sourceConnection xsi:type="archimate:Connection" id="3174a55b" source="2be1001e" target="0308d4c3" relationship="67e21821"/>
            # </child>
            elif ARCHI_TYPE in x.attrib and x.get(ARCHI_TYPE) == DIAGRAM_OBJECT:
                ae = x.get(u"archimateElement")
                aeDO = al.findDiagramObject(ae)[0].attrib
                aeid = aeDO[u"archimateElement"]
                aeElm = al.findElementByID(aeid)[0]

                logger.debug(u"%s[%s] " % (aeElm.get(u"name"), aeElm.get(ARCHI_TYPE)))

            elif ARCHI_TYPE in x.attrib and x.tag == u"sourceConnection":

                src = x.get(u"source")
                srcDO = al.findDiagramObject(src)[0].attrib
                sid = srcDO[u"archimateElement"]
                srcElm = al.findElementByID(sid)[0]

                trc = x.get(u"target")
                tgtDO = al.findDiagramObject(trc)[0].attrib
                tid = tgtDO[u"archimateElement"]
                tgtElm = al.findElementByID(tid)[0]

                rrc = x.get(u"relationship")
                relElm = al.findElementByID(rrc)[0]
                rid = relElm.get(ARCHI_TYPE)[10:]

                logger.debug(u"  S - %s -> [%s] -> %s" % ((srcElm.get(u"name"), rid, tgtElm.get(u"name"))))

            else:
                if u"name" in x.attrib and x.attrib.has_key(ARCHI_TYPE):
                    logger.info(u"Skipping - %s[%s] - %s" % (x.get(ARCHI_TYPE)[10:], x.get(u"id"), x.get(u"name")[:20]))
                else:
                    logger.debug(u"Skipping - %s[%s]" % (x.tag, x.get(u"id")))
        except:
            countInvalid += 1
            logger.error(u"Error - %s[%s]" % (x.tag, x.get(u"id")))

    logger.info(u"Validated %d Elements" % n)

    al.logTypeCounts()
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:72,代码来源:al_CleanArchimateRelationships.py


注:本文中的al_lib.ArchiLib.ArchiLib.findElementByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。