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


Python builder.E屬性代碼示例

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


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

示例1: voc

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def voc(self, pretty=False):

        annotations = []
        for annotation in self.iter_annotations():
            annotations.append(annotation.voc())
        
        element = E('annotation',
            E('folder', self.path[: -1*(len(self.file_name)+1)]),
            E('path', self.path),
            E('filename', self.file_name),
            E('size',
                E('width', str(self.width)),
                E('height', str(self.height)),
                E('depth', str(3))
            ),
            *annotations
        )
        
        if pretty:
            return ET.tostring(element, pretty_print=True).decode('utf-8')
        
        return element 
開發者ID:jsbroks,項目名稱:imantics,代碼行數:24,代碼來源:image.py

示例2: voc

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def voc(self):

        element = E('object',
            E('name', self.category.name),
            E('pose', self.metadata.get('pose', 'Unspecified')),
            E('truncated', str(1 if self.truncated() else 0)),
            E('difficult', str(self.metadata.get('difficult', 0))),
            E('bndbox',
                E('xmin', str(self.bbox._xmin)),
                E('ymin', str(self.bbox._ymin)),
                E('xmax', str(self.bbox._xmax)),
                E('ymax', str(self.bbox._ymax)),
            )
        )
        
        return element 
開發者ID:jsbroks,項目名稱:imantics,代碼行數:18,代碼來源:annotation.py

示例3: _getVignettes

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def _getVignettes(self, profile):
        result = []

        try:
            for v in self.profiles[profile]['vignettes_save']:
                result.append(
                    E('vignette',
                      E('beforeTitle', self.profiles[profile]['vignettes_save'][v]['beforeTitle'] if self.profiles[profile]['vignettes_save'][v]['beforeTitle'] else 'None'),
                      E('afterTitle', self.profiles[profile]['vignettes_save'][v]['afterTitle'] if self.profiles[profile]['vignettes_save'][v]['afterTitle'] else 'None'),
                      E('chapterEnd', self.profiles[profile]['vignettes_save'][v]['chapterEnd'] if self.profiles[profile]['vignettes_save'][v]['chapterEnd'] else 'None'),
                      level=v))

        except:
            pass

        return result 
開發者ID:rupor-github,項目名稱:fb2mobi,代碼行數:18,代碼來源:config.py

示例4: initialize

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def initialize(self):
        head = E("head")
        body = E("body")
        self.root = E("html", head, body, lang=self.language, xmlns="http://www.w3.org/1999/xhtml")
        self.head = head
        self.body = body
        meta = E("meta", content=self.MIMETYPE, charset=self.encoding)
        meta.attrib["http-equiv"] = "Content-Type"
        self.head.append(meta) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:11,代碼來源:HTML5parse.py

示例5: join

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def join(tokens, start, result):
    """Join tokens into a single string with spaces between."""
    texts = []
    if len(result) > 0:
        for e in result:
            for child in e.iter():
                if child.text is not None:
                    texts.append(child.text)
        return [E(result[0].tag, ' '.join(texts))] 
開發者ID:mcs07,項目名稱:ChemDataExtractor,代碼行數:11,代碼來源:actions.py

示例6: merge

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def merge(tokens, start, result):
    """Join tokens into a single string with no spaces."""
    texts = []
    if len(result) > 0:
        for e in result:
            for child in e.iter():
                if child.text is not None:
                    texts.append(child.text)
        return [E(result[0].tag, ''.join(texts))] 
開發者ID:mcs07,項目名稱:ChemDataExtractor,代碼行數:11,代碼來源:actions.py

示例7: _parse_tokens

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def _parse_tokens(self, tokens, i, actions=True):
        return [E(self.name or safe_name(tokens[i][1]), tokens[i][0])], i + 1 
開發者ID:mcs07,項目名稱:ChemDataExtractor,代碼行數:4,代碼來源:elements.py

示例8: split_uvvis_shape

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def split_uvvis_shape(tokens, start, result):
    """"""
    if result[0].text.endswith('sh') or result[0].text.endswith('br'):
        result.append(E('shape', result[0].text[-2:]))
        result[0].text = result[0].text[:-2] 
開發者ID:mcs07,項目名稱:ChemDataExtractor,代碼行數:7,代碼來源:table.py

示例9: extract_units

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def extract_units(tokens, start, result):
    """Extract units from bracketed after nu"""
    for e in result:
        for child in e.iter():
            if 'cm−1' in child.text:
                return [E('units', 'cm−1')]
    return [] 
開發者ID:mcs07,項目名稱:ChemDataExtractor,代碼行數:9,代碼來源:ir.py

示例10: _getProfiles

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def _getProfiles(self):
        result = []
        for p in self.profiles:
            result.append(
                E('profile',
                  E('hyphens', str(self.profiles[p]['hyphens'])),
                  E('hyphensReplaceNBSP', str(self.profiles[p]['hyphensReplaceNBSP'])),
                  E('dropcaps', str(self.profiles[p]['dropcaps'])),
                  E('tocMaxLevel', str(self.profiles[p]['tocMaxLevel'])),
                  E('tocKindleLevel', str(self.profiles[p]['tocKindleLevel'])),
                  E('tocBeforeBody', str(self.profiles[p]['tocBeforeBody'])),
                  E('tocType', str(self.profiles[p]['tocType'])),
                  E('css', self.profiles[p]['originalcss'], parse=str(self.profiles[p]['parse_css'])),
                  E('chapterOnNewPage', str(self.profiles[p]['chapterOnNewPage'])),
                  E('chapterLevel', str(self.profiles[p]['chapterLevel'])),
                  E('authorFormat', self.profiles[p]['authorFormat']),
                  E('bookTitleFormat', self.profiles[p]['bookTitleFormat']),
                  E('annotationTitle', self.profiles[p]['annotationTitle']),
                  E('tocTitle', self.profiles[p]['tocTitle']),
                  E('notesMode', self.profiles[p]['notesMode']),
                  E('notesBodies', self.profiles[p]['notesBodies']),
                  E('generateTOCPage', str(self.profiles[p]['generateTOCPage'])),
                  E('generateAnnotationPage', str(self.profiles[p]['generateAnnotationPage'])),
                  E('generateOPFGuide', str(self.profiles[p]['generateOPFGuide'])),
                  E('kindleRemovePersonalLabel', str(self.profiles[p]['kindleRemovePersonalLabel'])),
                  E('removePngTransparency', str(self.profiles[p]['removePngTransparency'])),
                  E('charactersPerPage', str(self.profiles[p]['charactersPerPage'])),
                  E('seriesPositions', str(self.profiles[p]['seriesPositions'])),
                  E('openBookFromCover', str(self.profiles[p]['openBookFromCover'])),
                  E('coverDefault', str(self.profiles[p]['coverDefault'])),
                  E('coverStamp', str(self.profiles[p]['coverStamp'])),
                  E('vignettes', *self._getVignettes(p)),
                  name=p,
                  description=self.profiles[p]['description']))

        return result 
開發者ID:rupor-github,項目名稱:fb2mobi,代碼行數:38,代碼來源:config.py

示例11: write

# 需要導入模塊: from lxml import builder [as 別名]
# 或者: from lxml.builder import E [as 別名]
def write(self):
        # yapf: disable
        config = E('settings',
            # pylint: disable=C0330
            E('debug', str(self.debug)),
            E('logFile', self.original_log_file) if self.original_log_file else E('logFile'),
            E('logLevel', self.log_level),
            E('consoleLevel', self.console_level),
            E('outputFormat', self.output_format),
            E('kindleCompressionLevel', str(self.kindle_compression_level)),
            E('noDropcapsSymbols', self.no_dropcaps_symbols),
            E('transliterate', str(self.transliterate)),
            E('screenWidth', str(self.screen_width)),
            E('screenHeight', str(self.screen_height)),
            E('defaultProfile', self.default_profile),
            E('noMOBIoptimization', str(self.noMOBIoptimization)),
            E('profiles', *self._getProfiles()),
            E('sendToKindle',
                E('send', str(self.send_to_kindle['send'])),
                E('deleteSendedBook', str(self.send_to_kindle['deleteSendedBook'])),
                E('smtpServer', self.send_to_kindle['smtpServer']),
                E('smtpPort', str(self.send_to_kindle['smtpPort'])),
                E('smtpLogin', self.send_to_kindle['smtpLogin']),
                E('smtpPassword', self.send_to_kindle['smtpPassword']) if self.send_to_kindle['smtpPassword'] else E('smtpPassword'),
                E('fromUserEmail', self.send_to_kindle['fromUserEmail']),
                E('toKindleEmail', self.send_to_kindle['toKindleEmail'])))
        # yapf: enable

        config_dir = os.path.dirname(self.config_file)
        if not os.path.exists(config_dir):
            os.makedirs(config_dir)

        with codecs.open(self.config_file, "w", 'utf-8') as f:
            f.write(str(etree.tostring(config, encoding="utf-8", pretty_print=True, xml_declaration=True), 'utf-8'))
            f.close() 
開發者ID:rupor-github,項目名稱:fb2mobi,代碼行數:37,代碼來源:config.py


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