o
    ie                     @   s   d Z ddlZzeZW n ey   G dd deZY nw zeZW n ey+   eZY nw dd Ze	dj
Zdd	d
dZeefddZdd Z		dddZdS )aS  
Part of the astor library for Python AST manipulation.

License: 3-clause BSD

Copyright (c) 2015 Patrick Maupin

Pretty-print strings for the decompiler

We either return the repr() of the string,
or try to format it as a triple-quoted string.

This is a lot harder than you would think.

This has lots of Python 2 / Python 3 ugliness.

    Nc                   @   s   e Zd ZdS )special_unicodeN)__name__
__module____qualname__ r   r   N/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/astor/string_repr.pyr      s    r   c                 C   sT   |  ddd  }dd |D }dd |D }| sdS dd |D }|o)t||kS )N
   c                 S   s   g | ]}|  qS r   )rstrip.0xr   r   r   
<listcomp>$       z&_properly_indented.<locals>.<listcomp>c                 S   s   g | ]}|r|qS r   r   r   r   r   r   r   %   r   Fc                 S   s    g | ]}t |t |  qS r   )lenlstripr   r   r   r   r   (   s     )splitmin)sline_indentmylistcountsr   r   r   _properly_indented"   s   r   z(\\|\"\"\"|\"$)z\\z""\"z\")\z""""c                    s8   || }  fdd| ddd D | ddd< d | S )ze Split the string up and force-feed some replacements
        to make sure it will round-trip OK
    c                 3   s    | ]} | V  qd S )Nr   r   replacementsr   r   	<genexpr>6   s    z&_prep_triple_quotes.<locals>.<genexpr>r	   N    )join)r   mysplitr   r   r   r   _prep_triple_quotes0   s   &
r"   c                 C   s   dt |  S )z<Return string's python representation in triple quotes.
    z"""%s""")r"   )r   r   r   r   string_triplequote_repr:   s   r#   F   d   c                 C   s   t | }t| tst| ts|S |rt| trd| S t|}| rYt|}| dd }	|dkr6|	s6|S ||k r<|S |t|  }
|rJ|	sJ|S || }||k rYt	| |
sY|S t
| }zt|| krkd|vrn|W S W |S W |S  tyz   Y |S w )zThere are a lot of reasons why we might not want to or
       be able to return a triple-quoted string.  We can always
       punt back to the default normal string.
    br   r	   )repr
isinstancer   
basestringbytesr   stripfindr   r   r#   eval	Exception)r   embeddedcurrent_lineuni_litmin_trip_strmax_linedefaultlen_slen_currentsecond_line_startr   	total_lenfancyr   r   r   pretty_string@   s>   r;   )Fr$   r%   )__doc__reunicoder   	NameErrorobjectr*   strr   compiler   r!   r   r"   r#   r;   r   r   r   r   <module>   s(   

