本文整理汇总了Python中xml.etree.ElementTree.SubElement.attrib["class"]方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.attrib["class"]方法的具体用法?Python SubElement.attrib["class"]怎么用?Python SubElement.attrib["class"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml.etree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.attrib["class"]方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_crypt_text
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def _add_crypt_text(self, oCardText, aSortedVampires):
"""Add the text of the crypt to the element tree"""
oCryptTextHead = SubElement(oCardText, "h4")
oCryptTextHead.attrib["class"] = "librarytype"
oCryptTextHead.text = "Crypt"
for tVampInfo, oCard in aSortedVampires:
oCardName = SubElement(oCardText, "h5")
oCardName.text = tVampInfo[2]
oList = SubElement(oCardText, "ul")
# Capacity
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Capacity:', 'label')
_add_span(oListItem, str(tVampInfo[1]), 'capacity')
# Group
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Group:', 'label')
_add_span(oListItem, str(oCard.group), 'group')
# Clan
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Clan:', 'label')
_add_span(oListItem, tVampInfo[3], 'clan')
# Disciplines
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Disciplines:', 'label')
_add_span(oListItem, self._gen_disciplines(oCard), 'disciplines')
# Text
_add_text(oCardText, oCard)
示例2: add_row
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def add_row(oCryptTBody, tVampInfo, oCard):
"""Add a row to the display table"""
oTR = SubElement(oCryptTBody, "tr")
# Card Count
oTD = SubElement(oTR, "td")
_add_span(oTD, "%dx" % tVampInfo[0], 'tablevalue')
# Card Name + Monger href
oTD = SubElement(oTR, "td")
oSpan = SubElement(oTD, "span")
oSpan.attrib["class"] = "tablevalue"
# May be able to get away without this, but being safe
self._gen_link(oCard, oSpan, tVampInfo[2], True)
oTD = SubElement(oTR, "td")
# Advanced status
if oCard.level is not None:
_add_span(oTD, '(Advanced)', 'tablevalue')
# Capacity
oTD = SubElement(oTR, "td")
_add_span(oTD, str(tVampInfo[1]), 'tablevalue')
# Disciplines
oTD = SubElement(oTR, "td")
_add_span(oTD, self._gen_disciplines(oCard), 'tablevalue')
# Title
oTD = SubElement(oTR, "td")
if len(oCard.title) > 0:
_add_span(oTD, [oTitle.name for oTitle in oCard.title][0],
'tablevalue')
# Clan
oTD = SubElement(oTR, "td")
_add_span(oTD, "%s (group %d)" % (tVampInfo[3], oCard.group),
'tablevalue')
示例3: _gen_tree
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def _gen_tree(self, oHolder):
"""Convert the Cards to a element tree containing 'nice' HTML"""
oDocRoot = Element('html', xmlns='http://www.w3.org/1999/xhtml',
lang='en')
oDocRoot.attrib["xml:lang"] = 'en'
oBody = self._add_header(oDocRoot, oHolder)
dCards = self._get_cards(oHolder.cards)
aSortedVampires = self._add_crypt(oBody, dCards)
aSortedLibCards = self._add_library(oBody, dCards)
if self._bDoText:
oCardText = SubElement(oBody, "div", id="cardtext")
oTextHead = SubElement(oCardText, "h3")
oTextHead.attrib["class"] = "cardtext"
_add_span(oTextHead, 'Card Texts')
self._add_crypt_text(oCardText, aSortedVampires)
self._add_library_text(oCardText, aSortedLibCards)
# Closing stuff
oGenerator = SubElement(oBody, "div")
_add_span(oGenerator, "Crafted with : Sutekh [ %s ]. [ %s ]" %
(SutekhInfo.VERSION_STR,
time.strftime('%Y-%m-%d', time.localtime())),
"generator")
pretty_xml(oDocRoot)
return oDocRoot
示例4: _add_text
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def _add_text(oElement, oCard):
"""Add the card text to the ElementTree line by line"""
oTextDiv = SubElement(oElement, "div")
oTextDiv.attrib["class"] = "text"
for sLine in oCard.text.splitlines():
oPara = SubElement(oTextDiv, 'p')
oPara.text = sLine
示例5: _add_library_text
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def _add_library_text(self, oCardText, aSortedLibCards):
"""Add the text of the library cards to the tree."""
def gen_requirements(oCard):
"""Extract the requirements from the card"""
oList = Element("ul")
# Clan requirements
aClan = [x.name for x in oCard.clan]
if len(aClan) > 0:
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Requires:', 'label')
_add_span(oListItem, "/".join(aClan), 'requirement')
# Cost
if oCard.costtype is not None:
# pylint: disable-msg=E1103
# SQLObject methods confuse pylint
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Cost:', 'label')
_add_span(oListItem, "%d %s" % (oCard.cost,
oCard.costtype), 'cost')
# Disciplines
sDisciplines = self._gen_disciplines(oCard)
if sDisciplines != "":
oListItem = SubElement(oList, "li")
_add_span(oListItem, 'Disciplines:', 'label')
_add_span(oListItem, sDisciplines, 'disciplines')
return oList
for sType, aList in aSortedLibCards:
oTypeHead = SubElement(oCardText, "h4")
oTypeHead.attrib["class"] = "libraryttype"
oTypeHead.text = sType
for sName in sorted([x[1] for x in aList[1:]]):
# pylint: disable-msg=E1101
# IAbstrctCard confuses pylint
oCard = IAbstractCard(sName)
oCardHead = SubElement(oCardText, "h5")
oCardHead.attrib["class"] = "cardname"
oCardHead.text = sName
oList = gen_requirements(oCard)
if len(oList) > 0:
# not empty, so add
oCardText.append(oList)
# Text
_add_text(oCardText, oCard)
示例6: _add_library
# 需要导入模块: from xml.etree.ElementTree import SubElement [as 别名]
# 或者: from xml.etree.ElementTree.SubElement import attrib["class"] [as 别名]
def _add_library(self, oBody, dCards):
"""Add the library cards to the tree"""
def start_section(oBody, dCards):
"""Set up the header for this section"""
(dLib, iLibSize) = self._extract_library(dCards)
aSortedLibCards = _sort_lib(self._group_sets(dLib))
oLib = SubElement(oBody, "div", id="library")
oLibTitle = SubElement(oLib, "h3", id="librarytitle")
_add_span(oLibTitle, "Library")
_add_span(oLibTitle, '[%d cards]' % iLibSize, 'stats',
'librarystats')
return oLib, aSortedLibCards
def add_row(oTBody, iCount, sName):
"""Add a row to the display table"""
# pylint: disable-msg=E1101
# IAbstrctCard confuses pylint
oCard = IAbstractCard(sName)
oTR = SubElement(oTBody, "tr")
oTD = SubElement(oTR, "td")
_add_span(oTD, '%dx' % iCount, 'tablevalue')
oTD = SubElement(oTR, "td")
oSpan = SubElement(oTD, "span")
oSpan.attrib["class"] = "tablevalue"
self._gen_link(oCard, oSpan, sName, False)
oLib, aSortedLibCards = start_section(oBody, dCards)
oLibTable = SubElement(oLib, "div")
oLibTable.attrib["class"] = "librarytable"
for sType, aList in aSortedLibCards:
oTypeHead = SubElement(oLibTable, "h4")
oTypeHead.attrib["class"] = "librarytype"
_add_span(oTypeHead, sType)
_add_span(oTypeHead, '[%d]' % aList[0], 'stats')
oTBody = SubElement(
SubElement(oLibTable, "table",
summary="Library card table"),
"tbody")
# Sort alphabetically within cards
for iCount, sName in sorted(aList[1:], key=lambda x: x[1]):
add_row(oTBody, iCount, sName)
return aSortedLibCards