當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。