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


Python HTMLParser.reset方法代码示例

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


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

示例1: start_seq

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def start_seq(self, attr):
        #if it has a template, use that; otherwise try for id;
        #otherwise take default sequence
        if 'template' in attr:
            templ = attr['template']
            self.handle_data(templ % self._seq)
            return
        elif 'id' in attr:
            id = attr['id']
        else:
            id = None
        increment = attr.get('inc', None)
        if not increment:
            output = self._seq.nextf(id)
        else:
            #accepts "no" for do not increment, or an integer.
            #thus, 0 and 1 increment by the right amounts.
            if increment.lower() == 'no':
                output = self._seq.thisf(id)
            else:
                incr = int(increment)
                output = self._seq.thisf(id)
                self._seq.reset(id, self._seq._this() + incr)
        self.handle_data(output) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:paraparser.py

示例2: reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def reset(self):
        self.elements = []
        self.processing = []
        HTMLParser.reset(self) 
开发者ID:archlinux,项目名称:arch-security-tracker,代码行数:6,代码来源:util.py

示例3: reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def reset(self):
        self.allData = []
        self.allhref = []
        HTMLParser.reset(self)

    #
    # Appends HTML file content to allData variable
    # 
开发者ID:nasa,项目名称:cFS-GroundSystem,代码行数:10,代码来源:CommandParser.py

示例4: reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def reset(self):
        self.allData = []
        HTMLParser.reset(self)

    #
    # Appends HTML file content to allData variable
    # 
开发者ID:nasa,项目名称:cFS-GroundSystem,代码行数:9,代码来源:HTMLDocsParser.py

示例5: __init__

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def __init__(self, filename=None, encoding='utf-8'):
        '''
            __init__ - Creates an Advanced HTML parser object. For read-only parsing, consider IndexedAdvancedHTMLParser for faster searching.

                @param filename <str>         - Optional filename to parse. Otherwise use parseFile or parseStr methods.
                @param encoding <str>         - Specifies the document encoding. Default utf-8

        '''
        HTMLParser.__init__(self)
        # Do not automatically convert charrefs in python3
        self.convert_charrefs = False

        # Encoding to use for this document
        self.encoding = encoding

        self._inTag = []
        self.root = None
        self.doctype = None

        self.reset = self._reset # Must assign after first call, otherwise members won't yet be present

        if filename is not None:
            self.parseFile(filename)

###########################################
#####        INTERNAL               #######
########################################### 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:29,代码来源:Parser.py

示例6: __getstate__

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def __getstate__(self):
        '''
            __getstate__ - Get state for pickling

                @return <dict>
        '''
        state = self.__dict__

        # Python2 compat
        del state['reset']

        return state 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:14,代码来源:Parser.py

示例7: __setstate__

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def __setstate__(self, state):
        '''
            __setstate - Restore state for loading pickle

                @param state <dict> - The state
        '''
        for key, value in state.items():
            setattr(self, key, value)

        # Python2 compat
        self.reset = self._reset 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:13,代码来源:Parser.py

示例8: _reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def _reset(self):
        '''
            _reset - reset this object. Assigned to .reset after __init__ call.
        '''
        HTMLParser.reset(self)

        self.root = None
        self.doctype = None
        self._inTag = [] 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:11,代码来源:Parser.py

示例9: feed

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def feed(self, contents):
        '''
            feed - Feed contents. Use  parseStr or parseFile instead.

            @param contents - Contents
        '''
        contents = stripIEConditionals(contents)
        try:
            HTMLParser.feed(self, contents)
        except MultipleRootNodeException:
            self.reset()
            HTMLParser.feed(self, "%s%s" %(addStartTag(contents, INVISIBLE_ROOT_TAG_START), INVISIBLE_ROOT_TAG_END)) 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:14,代码来源:Parser.py

示例10: parseStr

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def parseStr(self, html):
        '''
            parseStr - Parses a string and creates the DOM tree and indexes.

                @param html <str> - valid HTML
        '''
        self.reset()

        if isinstance(html, bytes):
            self.feed(html.decode(self.encoding))
        else:
            self.feed(html) 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:14,代码来源:Parser.py

示例11: __init__

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def __init__(self, indent='  ', encoding='utf-8'):
        '''
            Create a pretty formatter.

            @param indent <str/int>, Default '    ' [4 spaces] - Either a space/tab/newline that represents one level of indent, or an integer to use that number of spaces

            @param encoding <str/None>, Default 'utf-8', - Use this encoding for the document. None to not mess with encoding
        '''
        HTMLParser.__init__(self)

        # Do not automatically convert charrefs in python3
        self.convert_charrefs = False

        self.parsedData = []
        self.reset = self._reset
        self.decl = None
        self.currentIndentLevel = 0
        self.indent = indent
        self.encoding = encoding

        self.inPreformatted = 0

        self.root = None

        self._inTag = []
        self.doctype = None 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:28,代码来源:Formatter.py

示例12: feed

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def feed(self, contents):
        '''
            feed - Load contents

            @param contents - HTML contents
        '''
        contents = stripIEConditionals(contents)
        try:
            HTMLParser.feed(self, contents)
        except MultipleRootNodeException:
            self.reset()

            HTMLParser.feed(self, "%s%s" %(addStartTag(contents, INVISIBLE_ROOT_TAG_START), INVISIBLE_ROOT_TAG_END)) 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:15,代码来源:Formatter.py

示例13: _reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def _reset(self):
        HTMLParser.reset(self)
        self.currentIndentLevel = 0
        self.parsedData = []
        self._inTag = []
        self.root = None
        self.doctype = None
        self.inPreformatted = 0 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:10,代码来源:Formatter.py

示例14: parseStr

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def parseStr(self, html):
        '''
            parseStr - Parses a string and creates the DOM tree and indexes.

                @param html <str> - valid HTML
        '''
        self.reset()
        if isinstance(html, bytes):
            self.feed(html.decode(self.encoding))
        else:
            self.feed(html) 
开发者ID:kata198,项目名称:AdvancedHTMLParser,代码行数:13,代码来源:Formatter.py

示例15: reset

# 需要导入模块: from html.parser import HTMLParser [as 别名]
# 或者: from html.parser.HTMLParser import reset [as 别名]
def reset(self):
        HTMLParser.reset(self)
        self.data = []
        self.p = [] 
开发者ID:GateNLP,项目名称:semeval2019-hyperpartisan-bertha-von-suttner,代码行数:6,代码来源:htmlparser.py


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