当前位置: 首页>>代码示例>>Python>>正文


Python HTMLParser.feed方法代码示例

本文整理汇总了Python中six.moves.html_parser.HTMLParser.feed方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLParser.feed方法的具体用法?Python HTMLParser.feed怎么用?Python HTMLParser.feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.html_parser.HTMLParser的用法示例。


在下文中一共展示了HTMLParser.feed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: feed

# 需要导入模块: from six.moves.html_parser import HTMLParser [as 别名]
# 或者: from six.moves.html_parser.HTMLParser import feed [as 别名]
 def feed(self, string):
     try:
         HTMLParser.feed(self, string)
     except Exception as e:  # pragma: no cover
         import traceback
         traceback.print_exc()
         self.out.write(string)
开发者ID:daleathan,项目名称:pywb,代码行数:9,代码来源:html_rewriter.py

示例2: feed

# 需要导入模块: from six.moves.html_parser import HTMLParser [as 别名]
# 或者: from six.moves.html_parser.HTMLParser import feed [as 别名]
 def feed(self, data):
     data = re.compile(r'<!((?!DOCTYPE|--|\[))', re.IGNORECASE).sub(r'&lt;!\1', data)
     data = re.sub(r'<([^<>\s]+?)\s*/>', self._shorttag_replace, data)
     data = data.replace('&#39;', "'")
     data = data.replace('&#34;', '"')
     HTMLParser.feed(self, data)
     HTMLParser.close(self)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:9,代码来源:page.py

示例3: feed

# 需要导入模块: from six.moves.html_parser import HTMLParser [as 别名]
# 或者: from six.moves.html_parser.HTMLParser import feed [as 别名]
 def feed(self, *args, **kwargs):
     try:
         # With Python 2, super() cannot be used.
         # See the comment for __init__().
         HTMLParser.feed(self, *args, **kwargs)
     except self.TruncationCompleted as exc:
         self.truncate_at = exc.truncate_at
     else:
         self.truncate_at = None
开发者ID:52M,项目名称:pelican,代码行数:11,代码来源:utils.py

示例4: cmd_genpot

# 需要导入模块: from six.moves.html_parser import HTMLParser [as 别名]
# 或者: from six.moves.html_parser.HTMLParser import feed [as 别名]
def cmd_genpot(config, options):
    """Generate the gettext pot file"""

    os.chdir(config.source_dir)

    po_path = os.path.join(config.source_dir, 'po')
    if not os.path.isdir(po_path):
        os.mkdir(po_path)

    python_files = []
    for root, dirs_dummy, files in os.walk(config.source_dir):
        for file_name in files:
            if file_name.endswith('.py'):
                file_path = os.path.relpath(os.path.join(root, file_name),
                                            config.source_dir)
                python_files.append(file_path)
    python_files.sort()

    # First write out a stub .pot file containing just the translated
    # activity name, then have xgettext merge the rest of the
    # translations into that. (We can't just append the activity name
    # to the end of the .pot file afterwards, because that might
    # create a duplicate msgid.)
    pot_file = os.path.join('po', '%s.pot' % config.bundle_name)
    escaped_name = _po_escape(config.activity_name)
    f = open(pot_file, 'w')
    f.write('#: activity/activity.info:2\n')
    f.write('msgid "%s"\n' % escaped_name)
    f.write('msgstr ""\n')
    if config.summary is not None:
        escaped_summary = _po_escape(config.summary)
        f.write('#: activity/activity.info:3\n')
        f.write('msgid "%s"\n' % escaped_summary)
        f.write('msgstr ""\n')

    if config.description is not None:
        parser = HTMLParser()
        strings = []
        parser.handle_data = strings.append
        parser.feed(config.description)

        for s in strings:
            s = s.strip()
            if s:
                f.write('#: activity/activity.info:4\n')
                f.write('msgid "%s"\n' % _po_escape(s))
                f.write('msgstr ""\n')
    f.close()

    args = ['xgettext', '--join-existing', '--language=Python',
            '--keyword=_', '--add-comments=TRANS:', '--output=%s' % pot_file]

    args += python_files
    retcode = subprocess.call(args)
    if retcode:
        print('ERROR - xgettext failed with return code %i.' % retcode)
开发者ID:sugarlabs,项目名称:sugar-toolkit-gtk3,代码行数:58,代码来源:bundlebuilder.py

示例5: feed

# 需要导入模块: from six.moves.html_parser import HTMLParser [as 别名]
# 或者: from six.moves.html_parser.HTMLParser import feed [as 别名]
 def feed(self, string):
     try:
         HTMLParser.feed(self, string)
     except Exception:  # pragma: no cover
         # only raised in 2.6
         self.out.write(string)
开发者ID:chdorner,项目名称:pywb,代码行数:8,代码来源:html_rewriter.py


注:本文中的six.moves.html_parser.HTMLParser.feed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。