관리-도구
편집 파일: _markupbase.cpython-37.opt-1.pyc
B �A�[W? � @ sX d Z ddlZe�d�jZe�d�jZe�d�Ze�d�Ze�d�Z[G dd � d e �Z dS ) a Shared support for scanning document type declarations in HTML and XHTML. Backported for python-future from Python 3.3. Reason: ParserBase is an old-style class in the Python 2.7 source of markupbase.py, which I suspect might be the cause of sporadic unit-test failures on travis-ci.org with test_htmlparser.py. The test failures look like this: ====================================================================== ERROR: test_attr_entity_replacement (future.tests.test_htmlparser.AttributesStrictTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/edschofield/python-future/future/tests/test_htmlparser.py", line 661, in test_attr_entity_replacement [("starttag", "a", [("b", "&><"'")])]) File "/home/travis/build/edschofield/python-future/future/tests/test_htmlparser.py", line 93, in _run_check collector = self.get_collector() File "/home/travis/build/edschofield/python-future/future/tests/test_htmlparser.py", line 617, in get_collector return EventCollector(strict=True) File "/home/travis/build/edschofield/python-future/future/tests/test_htmlparser.py", line 27, in __init__ html.parser.HTMLParser.__init__(self, *args, **kw) File "/home/travis/build/edschofield/python-future/future/backports/html/parser.py", line 135, in __init__ self.reset() File "/home/travis/build/edschofield/python-future/future/backports/html/parser.py", line 143, in reset _markupbase.ParserBase.reset(self) TypeError: unbound method reset() must be called with ParserBase instance as first argument (got EventCollector instance instead) This module is used as a foundation for the html.parser module. It has no documented public API and should not be used directly. � Nz[a-zA-Z][-_.a-zA-Z0-9]*\s*z(\'[^\']*\'|"[^"]*")\s*z--\s*>z ]\s*]\s*>z]\s*>c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� ZdZ d d� Z d#dd�Zd$dd�Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"S )%� ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.c C s | j tkrtd��d S )Nz)_markupbase.ParserBase must be subclassed)� __class__r �RuntimeError)�self� r �M/opt/alt/python37/lib/python3.7/site-packages/future/backports/_markupbase.py�__init__6 s zParserBase.__init__c C s t d��d S )Nz.subclasses of ParserBase must override error())�NotImplementedError)r �messager r r �error; s zParserBase.errorc C s d| _ d| _d S )N� r )�lineno�offset)r r r r �reset? s zParserBase.resetc C s | j | jfS )z&Return current line number and offset.)r r )r r r r �getposC s zParserBase.getposc C sb ||kr|S | j }|�d||�}|rN| j| | _|�d||�}||d | _n| j| | | _|S )N� r )�rawdata�countr �rindexr )r �i�jr Znlines�posr r r � updateposK s zParserBase.updatepos� c C s� | j }|d }|||� dks&td��|||d � dkrB|d S |||d � dkrZdS t|�}|||d � dkr�| �|�S || d kr�| �|�S | �||�\}}|d k r�|S |dkr�d| _�x(||k �r�|| }|dk�r||d |� }|dk�r| �|� n | �|� |d S |d k�r@t ||�}|�s6dS |� � }n�|dk�r\| �||�\} }n�|| jk�rr|d }nj|d k�r�|dk�r�| �|d |�}n0|tddddg�k�r�| � d| � n | � d� n| � d|| � |d k r�|S q�W dS )N� z<!z$unexpected call to parse_declarationr �>)�-r ���z--�[r Zdoctyper z"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ�attlistZlinktype�link�elementz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration)r �AssertionError�len� parse_comment�parse_marked_section� _scan_name�_decl_othercharsZhandle_decl�unknown_decl�_declstringlit_match�end�_parse_doctype_subset�setr ) r r r r �nZdecltype�c�data�m�namer r r �parse_declaration[ sZ zParserBase.parse_declarationr c C s� | j }|||d � dks"td��| �|d |�\}}|dk rB|S |tddddd g�krjt�||d �}n>|td ddg�kr�t�||d �}n| �d ||d |� � |s�dS |r�|�d�}| � ||d |� � |� d�S )N� z<![z)unexpected call to parse_marked_section()r ZtempZcdata�ignoreZincludeZrcdata�if�elseZendifz+unknown status keyword %r in marked sectionr )r r"