U
    '1el                     @   s  d Z dZdZ ddlZdd Zddd	d
dddddddddddddddddddddd d!d"d#d$d%gZd&Zd'Zeed(d)d* eed(d+ Zd,Zd-e	 Zeed(d)d* eed(d+ Z
d.Zed/ d*e d0 e Zed* e d* e
 d* e ZeeZd1ZeeZd6d2d3Zd4d5 ZdS )7z3.3.0a|  
Module to analyze Python source code; for syntax coloring tools.

Interface::

    tags = fontify(pytext, searchfrom, searchto)

 - The 'pytext' argument is a string containing Python source code.
 - The (optional) arguments 'searchfrom' and 'searchto' may contain a slice in pytext.
 - The returned value is a list of tuples, formatted like this::
    [('keyword', 0, 6, None), ('keyword', 11, 17, None), ('comment', 23, 53, None), etc. ]

 - The tuple contents are always like this::
    (tag, startindex, endindex, sublist)

 - tag is one of 'keyword', 'string', 'comment' or 'identifier'
 - sublist is not used, hence always None.
z0.4    Nc                 C   s   | | |S N)joinsplit)srcseprep r   ;/tmp/pip-unpacked-wheel-109iniqw/reportlab/lib/PyFontify.pyreplace(   s    r
   asassertexecdelfromlambdareturnandelifglobalnottrybreakelseiforwhileclassexceptimportpasscontinuefinallyinprintdefforisraiseyieldwithz#[^\n]*z$q[^\\q\n]*(\\[\000-\377][^\\q\n]*)*qq'|"a  
    qqq
    [^\\q]*
    (
        (   \\[\000-\377]
        |   q
            (   \\[\000-\377]
            |   [^\q]
            |   q
                (   \\[\000-\377]
                |   [^\\q]
                )
            )
        )
        [^\\q]*
    )*
    qqq
 z(^|[^a-zA-Z0-9_.\"'])()z[ 	]*[A-Za-z_][A-Za-z_0-9.]*c                 C   s\  |d krt | }tj}tj}g }|j}d}d}d}	d}
d}|}|| |}|d krTqX| }||krhqX|d}|t | }|d }|dkr*||kr|dd }|d }n|d d }|d }||	||d f |d	krV|| |}|d k	rV| }||krV|d}|t | }||
||d f q>|d
krF||||d f q>||||d f q>|S )Ncommentstringkeyword
identifierr   z#'"   )r$   r   #)lenmatchREsearchidREappendstartgroup)ZpytextZ
searchfromZsearchtor:   ZidSearchtagsZtags_appendZ
commentTagZ	stringTagZ
keywordTagZidentifierTagr=   endmmatchcr   r   r	   fontifyd   sP    









rD   c                 C   sL   t | }| }|  t|}|D ]"\}}}}t|t|||  q$d S r   )openreadcloserD   r#   repr)pathftextr?   tagr=   r@   Zsublistr   r   r	   test   s    rM   )r   N)__version____doc__rer
   ZkeywordsListZ
commentPatpatZquotePatr   r   ZtripleQuotePatZ	nonKeyPatZkeyPatZmatchPatcompiler9   ZidKeyPatr;   rD   rM   r   r   r   r	   <module>   sd                          


7