本文整理汇总了Python中al_lib.ArchiLib.ArchiLib.findDiagramObject方法的典型用法代码示例。如果您正苦于以下问题:Python ArchiLib.findDiagramObject方法的具体用法?Python ArchiLib.findDiagramObject怎么用?Python ArchiLib.findDiagramObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类al_lib.ArchiLib.ArchiLib
的用法示例。
在下文中一共展示了ArchiLib.findDiagramObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DrawModels
# 需要导入模块: from al_lib.ArchiLib import ArchiLib [as 别名]
# 或者: from al_lib.ArchiLib.ArchiLib import findDiagramObject [as 别名]
class DrawModels(object):
fileArchimate= None
n = None
al = None
width = None
height = None
def __init__(self, fileArchimate):
self.fileAchimate = fileArchimate
self.n = 0
self.al = ArchiLib(fileArchimate)
self.start_time = ArchiLib.startTimer()
self.width = u"120"
self.height = u"55"
def createArchimateElement(self, tag, folder, attrib):
self.al.insertNode(tag, folder, attrib, new=False)
AE_ID = attrib[ID]
return AE_ID
def createArchimateRelations(self, tag, folder, attrib):
self.al.insertRel(tag, folder, attrib, new=False)
AR_ID = attrib[ID]
return AR_ID
# <element
# xsi:type="archimate:ArchimateDiagramModel"
# id="66de3166"
# name="Info">
def createDiagramModel(self, tag=None, folder=None, attrib=None):
if tag is None and folder is None and attrib is None:
tag = u"element"
folder = u"Views"
attrib = dict()
attrib[NAME] = u"DM-TDO%d" % self.n
attrib[ARCHI_TYPE] = DIAGRAM_MODEL
self.al.insertNode(tag, folder, attrib)
DMO_ID = attrib[ID]
DMO = self.al.findDiagramModel(attrib[ID])
if len(DMO) == 1:
DMO = DMO[0]
else:
logger.error(u"Diagram Model Not Found")
raise LookupError(u"Ops")
return DMO
else:
self.al.insertNode(tag, folder, attrib)
DMO_ID = attrib[ID]
DMO = self.al.findDiagramModel(attrib[ID])
if len(DMO) == 1:
DMO = DMO[0]
else:
logger.error(u"Diagram Model Not Found")
raise LookupError(u"Ops")
# <child
# xsi:type="archimate:DiagramObject"
# id="ffc36ce0"
# lineColor="#000000"
# textAlignment="2"
# fillColor="#00ffff"
# archimateElement="4b326945">
# </child>
def createDiagramObject(self, DMO, AE_ID, Bounds):
tag = u"child"
attrib = dict()
attrib[ID] = self.al.getID()
attrib[ARCHI_TYPE] = DIAGRAM_OBJECT
attrib[u"lineColor"] = u"#000000"
attrib[u"textAlignment"] = u"2"
attrib[u"targetConnections"] = u""
attrib[u"fillColor"] = u"#ffff00"
attrib[u"archimateElement"] = AE_ID
elm = etree.Element(tag, attrib, nsmap=NS_MAP)
DMO.append(elm)
DOE = self.al.findDiagramObject(attrib[ID])
if len(DOE) == 1:
DOE = DOE[0]
else:
logger.error(u"Diagram Object Not Found")
raise LookupError(u"Ops")
self.createBounds(DOE, Bounds)
#.........这里部分代码省略.........
示例2: cleanArchimateRelationships
# 需要导入模块: from al_lib.ArchiLib import ArchiLib [as 别名]
# 或者: from al_lib.ArchiLib.ArchiLib import findDiagramObject [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()