Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/future/backports/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/future/backports/__pycache__/_markupbase.cpython-36.pyc

3

�uGhW?�@sXdZddlZejd�jZejd�jZejd�Zejd�Zejd�Z[Gdd	�d	e	�Z
dS)
aShared 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�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdZ	d
d�Z
d#dd�Zd$dd�Zdd�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.cCs|jtkrtd��dS)Nz)_markupbase.ParserBase must be subclassed)�	__class__r�RuntimeError)�self�r�C/root/tmp/pip-build-gzoz1_uw/future/future/backports/_markupbase.py�__init__6s
zParserBase.__init__cCstd��dS)Nz.subclasses of ParserBase must override error())�NotImplementedError)r�messagerrr�error;szParserBase.errorcCsd|_d|_dS)N�r)�lineno�offset)rrrr�reset?szParserBase.resetcCs|j|jfS)z&Return current line number and offset.)r
r)rrrr�getposCszParserBase.getposcCsb||kr|S|j}|jd||�}|rN|j||_|jd||�}||d|_n|j|||_|S)N�
r)�rawdata�countr
�rindexr)r�i�jr�nlines�posrrr�	updateposKszParserBase.updatepos�c
Cs�|j}|d}|||�dks&td��|||d�dkrB|dS|||d�dkrZdSt|�}|||d�dkr�|j|�S||d	kr�|j|�S|j||�\}}|d
kr�|S|dkr�d|_�x(||k�r�||}|dk�r||d|�}|dk�r|j|�n
|j|�|dS|dk�r@t	||�}|�s6dS|j
�}n�|d
k�r\|j||�\}	}n�||jk�rr|d}nj|d	k�r�|dk�r�|j|d|�}n0|tddddg�k�r�|j
d|�n
|j
d�n|j
d||�|d
kr�|Sq�WdS)N�z<!z$unexpected call to parse_declarationr�>�-rz--�[r�doctypez"'�4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ�attlist�linktype�link�elementz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration)rr���r%r%)r�AssertionError�len�
parse_comment�parse_marked_section�
_scan_name�_decl_otherchars�handle_decl�unknown_decl�_declstringlit_match�end�_parse_doctype_subset�setr)
rrrr�n�decltype�c�data�m�namerrr�parse_declaration[sZ











zParserBase.parse_declarationrcCs�|j}|||d�dks"td��|j|d|�\}}|dkrB|S|tddddd	g�krjtj||d�}n>|td
ddg�kr�tj||d�}n|jd
||d|��|s�dS|r�|jd�}|j	||d|��|j
d�S)N�z<![z)unexpected call to parse_marked_section()r�temp�cdata�ignore�include�rcdata�if�else�endifz+unknown status keyword %r in marked sectionrr%)rr&r*r1�_markedsectionclose�search�_msmarkedsectioncloser�startr-r/)rr�reportr�sectNamer�matchrrrr)�s 
zParserBase.parse_marked_sectioncCsj|j}|||d�dkr$|jd�tj||d�}|s<dS|r`|jd�}|j||d|��|jd�S)N�z<!--z"unexpected call to parse_comment()rrr%)rr�
_commentcloserCrE�handle_commentr/)rrrFrrHrrrrr(�s

zParserBase.parse_commentc
Cs@|j}t|�}|}�x&||k�r:||}|dk�r@|||d�}|dkrNdS|dkrt|j||d�|jd|�|d|kr�dS|d|kr�dS|||d�dkr�|j|dd	�}|dkr|Sq|j|d|�\}}|dkr�dS|td
ddd
g�k�r|j||d�|jd|�t|d|�}	|	||�}|dk�r8|Sq|dk�r�|d|k�r\dS|j|d|�\}}|dk�r~|S||dk�r8|d}q|dk�r
|d}x&||k�r�||j��r�|d}�q�W||k�r||dk�r�|S|j||�|jd�ndSq|j��r|d}q|j||�|jd|�qWdS)N�<rrz<!z*unexpected char in internal subset (in %r)rIz<!--r)rFr!r$�entity�notationz)unknown declaration %r in internal subset�_parse_doctype_�%�;�]rz%unexpected char after internal subsetz%unexpected char %r in internal subsetr%r%r%r%r%r%r%r%)	rr'rrr(r*r1�getattr�isspace)
rr�declstartposrr2rr4�sr7�methrrrr0�sn










z ParserBase._parse_doctype_subsetcCsF|j||�\}}|dkrdS|j}d||d�krB|jd|�dSdS)Nrrr%r%r%)r*r�find)rrrUr7rrrrr�_parse_doctype_elementsz!ParserBase._parse_doctype_elementcCs�|j}|j||�\}}|||d�}|dkr2d	S|dkrB|dS�xv|j||�\}}|dkrb|S|||d�}|dkr~d
S|dkr�d||d�kr�|jd|�d}ndSx |||d�j�r�|d}q�W||d�s�dSn|j||�\}}|||d�}|�s
d
S|dk�rLt||�}|�r.|j�}ndS|||d�}|�sLdS|dk�r�||d�dk�rldS|j|d|�\}}|dk�r�|S|||d�}|�s�dS|dkrF|dSqFWdS)Nrrrr�(�)z'"�#r%r%r%r%r%r%r%r%r%)rr*rXrTr.r/)rrrUrr7rr4r6rrr�_parse_doctype_attlistsZ




z!ParserBase._parse_doctype_attlistcCs�|j||�\}}|dkr|S|j}xl|||d�}|s<dS|dkrL|dS|dkrpt||�}|sfdS|j�}q$|j||�\}}|dkr$|Sq$WdS)Nrrrz'"r%r%)r*rr.r/)rrrUr7rrr4r6rrr�_parse_doctype_notationXs$

z"ParserBase._parse_doctype_notationcCs�|j}|||d�dkrV|d}x6|||d�}|s<dS|j�rN|d}q$Pq$Wn|}|j||�\}}|dkrv|Sxp|j||d�}|s�dS|dkr�t||�}|r�|j�}q�dSqx|dkr�|dS|j||�\}}|dkrx|SqxWdS)	NrrPrz'"rr%r%r%)rrTr*r.r/)rrrUrrr4r7r6rrr�_parse_doctype_entityos8


z ParserBase._parse_doctype_entitycCs�|j}t|�}||krdSt||�}|r\|j�}|j�}|t|�|krLdS|j�|j�fS|j||�|jd|||d��dS)Nrzexpected name token at %r�r%)Nr%r%)Nr%)	rr'�_declname_match�group�strip�lowerr/rr)rrrUrr2r6rVr7rrrr*�s
zParserBase._scan_namecCsdS)Nr)rr5rrrr-�szParserBase.unknown_declN)r)r)�__name__�
__module__�__qualname__�__doc__rrrrrr+r8r)r(r0rYr]r^r_r*r-rrrrr2s"
R

C9$r)rh�re�compilerHrar.rJrBrD�objectrrrrr�<module>!s




Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists