本文整理汇总了Python中xml.dom.minidom.Document.cT方法的典型用法代码示例。如果您正苦于以下问题:Python Document.cT方法的具体用法?Python Document.cT怎么用?Python Document.cT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml.dom.minidom.Document
的用法示例。
在下文中一共展示了Document.cT方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: todom
# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import cT [as 别名]
def todom(self):
""" Return the manifest as DOM tree """
doc = Document()
docE = doc.cE(self.manifestType)
if self.manifestType == "assemblyBinding":
cfg = doc.cE("configuration")
win = doc.cE("windows")
win.aChild(docE)
cfg.aChild(win)
doc.aChild(cfg)
else:
doc.aChild(docE)
if self.manifestType != "dependentAssembly":
docE.setA("xmlns", "urn:schemas-microsoft-com:asm.v1")
if self.manifestType != "assemblyBinding":
docE.setA("manifestVersion", ".".join([str(i) for i in self.manifestVersion]))
if self.noInheritable:
docE.aChild(doc.cE("noInheritable"))
if self.noInherit:
docE.aChild(doc.cE("noInherit"))
aId = doc.cE("assemblyIdentity")
if self.type:
aId.setAttribute("type", self.type)
if self.name:
aId.setAttribute("name", self.name)
if self.language:
aId.setAttribute("language", self.language)
if self.processorArchitecture:
aId.setAttribute("processorArchitecture", self.processorArchitecture)
if self.version:
aId.setAttribute("version", ".".join([str(i) for i in self.version]))
if self.publicKeyToken:
aId.setAttribute("publicKeyToken", self.publicKeyToken)
if aId.hasAttributes():
docE.aChild(aId)
else:
aId.unlink()
if self.applyPublisherPolicy != None:
ppE = doc.cE("publisherPolicy")
if self.applyPublisherPolicy:
ppE.setA("apply", "yes")
else:
ppE.setA("apply", "no")
docE.aChild(ppE)
if self.description:
descE = doc.cE("description")
descE.aChild(doc.cT(self.description))
docE.aChild(descE)
if self.requestedExecutionLevel in ("asInvoker", "highestAvailable", "requireAdministrator"):
tE = doc.cE("trustInfo")
tE.setA("xmlns", "urn:schemas-microsoft-com:asm.v3")
sE = doc.cE("security")
rpE = doc.cE("requestedPrivileges")
relE = doc.cE("requestedExecutionLevel")
relE.setA("level", self.requestedExecutionLevel)
if self.uiAccess:
relE.setA("uiAccess", "true")
else:
relE.setA("uiAccess", "false")
rpE.aChild(relE)
sE.aChild(rpE)
tE.aChild(sE)
docE.aChild(tE)
if self.dependentAssemblies:
for assembly in self.dependentAssemblies:
if self.manifestType != "assemblyBinding":
dE = doc.cE("dependency")
if assembly.optional:
dE.setAttribute("optional", "yes")
daE = doc.cE("dependentAssembly")
adom = assembly.todom()
for child in adom.documentElement.childNodes:
daE.aChild(child.cloneNode(False))
adom.unlink()
if self.manifestType != "assemblyBinding":
dE.aChild(daE)
docE.aChild(dE)
else:
docE.aChild(daE)
if self.bindingRedirects:
for bindingRedirect in self.bindingRedirects:
brE = doc.cE("bindingRedirect")
brE.setAttribute(
"oldVersion", "-".join([".".join([str(i) for i in part]) for part in bindingRedirect[0]])
)
brE.setAttribute("newVersion", ".".join([str(i) for i in bindingRedirect[1]]))
docE.aChild(brE)
if self.files:
for file_ in self.files:
fE = doc.cE("file")
for attr in ("name", "hashalg", "hash"):
val = getattr(file_, attr)
if val:
fE.setA(attr, val)
docE.aChild(fE)
return doc
示例2: todom
# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import cT [as 别名]
def todom(self):
""" Return the manifest as DOM tree """
doc = Document()
docE = doc.cE(self.manifestType)
if self.manifestType == "assemblyBinding":
cfg = doc.cE("configuration")
win = doc.cE("windows")
win.aChild(docE)
cfg.aChild(win)
doc.aChild(cfg)
else:
doc.aChild(docE)
if self.manifestType != "dependentAssembly":
docE.setA("xmlns", "urn:schemas-microsoft-com:asm.v1")
if self.manifestType != "assemblyBinding":
docE.setA("manifestVersion",
".".join([str(i) for i in self.manifestVersion]))
if self.noInheritable:
docE.aChild(doc.cE("noInheritable"))
if self.noInherit:
docE.aChild(doc.cE("noInherit"))
aId = doc.cE("assemblyIdentity")
if self.type:
aId.setAttribute("type", self.type)
if self.name:
aId.setAttribute("name", self.name)
if self.language:
aId.setAttribute("language", self.language)
if self.processorArchitecture:
aId.setAttribute("processorArchitecture",
self.processorArchitecture)
if self.version:
aId.setAttribute("version",
".".join([str(i) for i in self.version]))
if self.publicKeyToken:
aId.setAttribute("publicKeyToken", self.publicKeyToken)
if aId.hasAttributes():
docE.aChild(aId)
else:
aId.unlink()
if self.applyPublisherPolicy != None:
ppE = doc.cE("publisherPolicy")
if self.applyPublisherPolicy:
ppE.setA("apply", "yes")
else:
ppE.setA("apply", "no")
docE.aChild(ppE)
if self.description:
descE = doc.cE("description")
descE.aChild(doc.cT(self.description))
docE.aChild(descE)
if self.requestedExecutionLevel in ("asInvoker", "highestAvailable",
"requireAdministrator"):
tE = doc.cE("trustInfo")
tE.setA("xmlns", "urn:schemas-microsoft-com:asm.v3")
sE = doc.cE("security")
rpE = doc.cE("requestedPrivileges")
relE = doc.cE("requestedExecutionLevel")
relE.setA("level", self.requestedExecutionLevel)
if self.uiAccess:
relE.setA("uiAccess", "true")
else:
relE.setA("uiAccess", "false")
rpE.aChild(relE)
sE.aChild(rpE)
tE.aChild(sE)
docE.aChild(tE)
if self.dependentAssemblies:
for assembly in self.dependentAssemblies:
if self.manifestType != "assemblyBinding":
dE = doc.cE("dependency")
if assembly.optional:
dE.setAttribute("optional", "yes")
daE = doc.cE("dependentAssembly")
adom = assembly.todom()
for child in adom.documentElement.childNodes:
daE.aChild(child.cloneNode(False))
adom.unlink()
if self.manifestType != "assemblyBinding":
dE.aChild(daE)
docE.aChild(dE)
else:
docE.aChild(daE)
if self.bindingRedirects:
for bindingRedirect in self.bindingRedirects:
brE = doc.cE("bindingRedirect")
brE.setAttribute("oldVersion",
"-".join([".".join([str(i)
for i in
part])
for part in
bindingRedirect[0]]))
brE.setAttribute("newVersion",
".".join([str(i) for i in bindingRedirect[1]]))
docE.aChild(brE)
if self.files:
for file_ in self.files:
fE = doc.cE("file")
for attr in ("name", "hashalg", "hash"):
val = getattr(file_, attr)
#.........这里部分代码省略.........