当前位置: 首页>>代码示例>>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;未经允许,请勿转载。