o
    ¯\%YÌÀ  ã                   @   s¨  d Z dZddlZddlZddlZddlZddlZddlmZ	m
Z ddlmZ ddlmZ ddlmZmZmZ zddlZW n eyI   ddlZY nw zddlmZ W n ey_   ddlZY nw zddlZe ¡ d	kZW n   d
ZY dd„ ZG dd„ dƒZeejƒfdd„Z [dd„ Z!e"e#ffdd„Z$dd„ Z%e�r(edƒZ&e'Z(e)Z*e)e'fZ+dd„ Z,dñdd„Z-dñdd„Z.dñdd„Z/dñd d!„Z0e1Z2d"d#„ Z3d$d%„ Z4d&d'„ Z5d(d)„ Z6d*d+„ Z7d,d-„ Z8d.d/„ Z9dd0l:m;Z;m<Z<m=Z= dd1l>m?Z?m@Z@ dòd2d3„ZAe?ZBdòd4d5„ZCdñd6d7„ZDd8d9„ ZEd:d;„ ZFd<d=„ ZGd>d?„ ZHddlIZIeJeId@ƒZK[IdAdB„ ZLdòdCdD„ZMdEdF„ ZNn„e)Z(eOZ*ePZ+ejQdGk�r9dHd„ Z,ndId„ Z,dñdJd„Z-dñdKd!„Z0dLdM„ Z2dNd%„ Z4dOd'„ Z5dPd)„ Z6dñdQd„Z.dñdRd„Z/dSd+„ Z7dTd-„ Z8dUd/„ Z9e1Z3ddVl@m@Z@ dòdWd3„ZAeAZCe@ZBdñdXd7„ZDddYl:mRZ;mSZ<mTZ= dZd9„ ZEd[d;„ ZFd\d=„ ZGd]d?„ ZHdód^d_„ZKeKd`ƒ eUZLdadF„ ZNdòdbdc„ZVdôdedf„ZWG dgdh„ dheXƒZYejZdik�rãddl[Z[ddl\Z\djdkdkdldmdmdndndodpdqdqdrdsdtœZ]dõdvdw„Z^ndódxdw„Z^ddlZej_ `eja¡Zbej_ ceb¡�rýeb�pej_ deb¡Ze[zea W n	   ejfd ZaY ddlgZgddlhZhz^eiZjej ZkeVejdy��s,eldzej ƒ‚ej_ mej_ nejjo¡¡Zpepejq Zrej_ `ep¡Zsesejq ZteuerƒZveuetƒZweretepesej_jnej_jmejxejqeuejqƒf	d{d|„Zyd}d~„ Zzegjgehjheeej_j{fdd€„Z|W n   ej_ }ea¡ZkdZjd�d~„ Zzegjgfd‚d€„Z|Y [g[hek�o¢ej_ }ej_ ~ea¡d dƒ ¡Zd„d…„ Z€d†d‡„ Z�dˆd‰„ Z‚dödŠd‹„ZƒdŒd�„ Z„dŽd�„ Z…d�d‘„ Z†ejdd’… d“k�rÞzddl‡Zˆddl‰ZŠd”Z‹W n1   dZ‹Y n*zdd•lŒm�Z� W n e�y   zddl�Z�W n e�y    dZ�Y nw Y nw e�duZ‹G d–d—„ d—ƒZŽd˜d™„ Z�dòdšd›„Z�dœd�„ Z‘d÷dŸd „Z’e�s;ddl“Z“ddl”Z”e“j•Z•e” –¡ j—fd¡d¢„Z˜[”[“ndd£l™m•Z• dd¤lšm›Z› ddlZe›ejœfd¥d¢„Z˜[›[dže•e˜fd¦d§„Z�[•[˜d÷d¨d©„Zždød«d¬„ZŸej_j}fd­d®„Z ej_j¡ej_jnfd¯d°„Z¢ej_j¡ej_jnej£fd±d²„Z¤ej_j}ej_jnej_j¥ej¦fd³d´„Z§e�r±ej¨ddµ… d¶k�r±dd·l©mªZ« d¸d¹„ Z¬nddl­Z­dºd¹„ Z¬d»d¼„ Z®d½d¾„ Z¯G d¿dÀ„ dÀe°ƒZ±G dÁdÂ„ dÂe±ƒZ²dÃdÄ„ Z³G dÅdÆ„ dÆƒZ´dÇdÈ„ ZµdÉdÊ„ Z¶dùdËdÌ„Z·G dÍdÎ„ dÎƒZ¸G dÏdÐ„ dÐƒZ¹dÑdÒ„ ZºdÓdÔ„ Z»dÕdÖ„ Z¼e�rd×dØ„ Z½ndÙdØ„ Z½ddl¾Z¾dÚdÛ„ Z¿dÜdÝ„ ZÀdÞdß„ ZÁdúdádâ„ZÂdñdãdä„ZÃdådæ„ ZÄG dçdè„ dèe)ƒZÅG dédê„ dêe)ƒZÆdëdì„ ZÇG dídî„ dîejÈƒZÉG dïdð„ dðe°ƒZÊdS )ûz3.3.0z6Gazillions of miscellaneous internal utility functionsé    N)ÚdecodestringÚencodestring)ÚisPy3)ÚwarnOnce)Úget_rl_tempfileÚget_rl_tempdirÚ
_rl_getuid)Úmd5ÚPyPyFc                 C   ó   t | ƒt tƒkS ©N)ÚtypeÚ
isFunction©Úv© r   úE/var/www/html/env/lib/python3.10/site-packages/reportlab/lib/utils.pyr      ó   r   c                   @   s   e Zd Zdd„ ZdS )Úcc                 C   ó   d S r   r   ©Úselfr   r   r   Úm!   s    zc.mN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r       s    r   c                 C   s   t | ƒ|kS r   )r   )r   Úmtr   r   r   ÚisMethod#   ó   r   c                 C   r   r   )r   Úsysr   r   r   r   ÚisModule'   r   r    c                 C   s
   t | |ƒS r   )Ú
isinstance)r   Ú_str   r   r   ÚisSeq*   ó   
r#   c                 C   ó
   t | tƒS r   ©r!   Ústrr   r   r   r   ÚisNative-   r$   r(   c                 C   s$   t t| ƒr
| ƒ ¡ S |  d¡ƒ ¡ S )NÚutf8)r	   ÚisBytesÚencodeÚ	hexdigest©Úsr   r   r   Ú	_digester8   s   $r/   r)   c                 C   ó   t | tƒr| S |  |¡S r   )r!   Úbytesr+   ©r   Úencr   r   r   ÚasBytes;   ó   r4   c                 C   r0   r   ©r!   r'   Údecoder2   r   r   r   Ú	asUnicode>   r5   r8   c                 C   ó*   t | tƒr| S t | tƒr|  |¡S t| ƒS r   )r!   r'   r1   r7   r2   r   r   r   ÚasUnicodeExA   ó   *r:   c                 C   ó   t | |d�S ©N)r3   )r8   r2   r   r   r   ÚasNativeD   r   r>   c                 C   s
   t | gƒS r   )r1   )Úir   r   r   Úint2ByteI   r$   r@   c                 C   s   t | ttfƒS r   )r!   r'   r1   r   r   r   r   ÚisStrL   ó   rA   c                 C   r%   r   )r!   r1   r   r   r   r   r*   O   r$   r*   c                 C   r%   r   r&   r   r   r   r   Ú	isUnicodeR   r$   rC   c                 C   r%   r   ©r!   r   r   r   r   r   ÚisClassU   r$   rE   c                 C   s\   t | ttttttttt	t
tttjtjtjtjtjtjtjtjtjtjtjtjtjtjfƒ S r   )r!   ÚfloatÚintr   ÚtupleÚlistÚdictr'   r1   ÚcomplexÚboolÚsliceÚ_rl_NoneTypeÚtypesÚFunctionTypeÚ
LambdaTypeÚCodeTypeÚMappingProxyTypeÚSimpleNamespaceÚGeneratorTypeÚ
MethodTypeÚBuiltinFunctionTypeÚBuiltinMethodTypeÚ
ModuleTypeÚTracebackTypeÚ	FrameTypeÚGetSetDescriptorTypeÚMemberDescriptorType©Úxr   r   r   ÚisNonPrimitiveInstanceX   s   ûr`   c                 C   s   t | tƒ S r   rD   r   r   r   r   Úinstantiated`   r   ra   )Úascii_lettersÚascii_uppercaseÚascii_lowercase)ÚBytesIOÚStringIOc                 C   ó   | rt | ƒS t ƒ S ©z#unified StringIO instance interface)re   ©Úbufr   r   r   Ú
getBytesIOf   ó   rk   c                 C   rg   rh   ©rf   ri   r   r   r   ÚgetStringIOm   rl   rn   c                 C   s0   t | tƒr
|  |¡S t | tƒr| S t| ƒ |¡S r   )r!   r'   r+   r1   ©r_   r3   r   r   r   Úbytestrs   ó
   


rp   c                 C   s   t t | ¡ƒ ¡  d¡S ©NÚlatin1)Úbase64_encodestringÚpickleÚdumpsÚstripr7   ©Úargsr   r   r   Úencode_label{   r5   rz   c                 C   s   t  t|  d¡ƒ¡S rr   )ru   ÚloadsÚbase64_decodestringr+   ©Úlabelr   r   r   Údecode_label~   ó   r   c                 C   ó   t | tƒs
|  d¡S | S ©zconverts first 256 unicodes 1-1rs   r6   r-   r   r   r   Ú
rawUnicode�   ó   rƒ   c                 C   ó   t | tƒr
|  d¡S | S r‚   ©r!   r'   r+   r-   r   r   r   ÚrawBytes…   r„   r‡   Úexecc                 C   s*   t | tƒr| S tt | tƒr| n|  d¡ƒS rr   )r!   rG   Úordr'   r7   r-   r   r   r   Úchar2int‹   r;   rŠ   c                 C   s   |j |ur
| |¡‚|‚r   )Ú__traceback__Úwith_traceback)Útr   Úbr   r   r   Ú
rl_reraise�   s   

r�   c                  K   ó*   dd l }|  ¡ D ]
\}}t|||ƒ qd S ©Nr   )ÚbuiltinsÚitemsÚsetattr)Úkwdr’   Úkr   r   r   r   Úrl_add_builtins‘   ó   ÿr—   i   c                 C   s   t | ƒ ¡ S r   )r	   r,   r-   r   r   r   r/   š   r   c                 C   s   t dd„ t| ƒ ¡ D ƒdƒS )Nc                 S   s   g | ]}d t |ƒ ‘qS )z%02x©r‰   ©Ú.0r_   r   r   r   Ú
<listcomp>Ÿ   ó    z_digester.<locals>.<listcomp>Ú )Újoinr	   Údigestr-   r   r   r   r/   ž   s   c                 C   r0   r   r†   r2   r   r   r   r4   ¡   r5   c                 C   r<   r=   )r4   r2   r   r   r   r>   ¤   r   c                 C   s   t | ƒS r   )Úunichrr   r   r   r   ÚuniChr§   ó   r¢   c                 C   r%   r   )r!   Ú
basestringr   r   r   r   rA   ª   r$   c                 C   r%   r   r&   r   r   r   r   r*   ­   r$   c                 C   r%   r   )r!   Úunicoder   r   r   r   rC   °   r$   c                 C   r0   r   ©r!   r¥   r7   r2   r   r   r   r8   ³   r5   c                 C   r9   r   )r!   r¥   r'   r7   r2   r   r   r   r:   ¶   r;   c                 C   s   t | tjtfƒS r   )r!   rO   Ú	ClassTyper   r   r   r   r   rE   ¹   r   c                 C   sÆ   t | tjƒpbt | g t‘t‘t‘t‘t‘t‘t	‘t
‘t‘t‘t‘t‘t‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj‘tj ‘tj!‘tj"‘tj#‘R ƒ S r   )$r!   rO   ÚInstanceTyperF   rG   Úlongr   rH   rI   rJ   rL   r¥   r'   ÚbufferrK   rM   ÚNoneTyperP   rQ   rR   rU   r§   ÚUnboundMethodTyperV   rW   rX   rY   ÚFileTypeÚ
XRangeTyperZ   r[   ÚEllipsisTypeÚDictProxyTypeÚNotImplementedTyper\   r]   r^   r   r   r   r`   ¼   sN   Lÿÿÿÿþþþþýýýýüüüüûû
ûc                 C   s   t | tƒ o
t| dƒS )NÚ	__class__)r!   r   Úhasattrr   r   r   r   ra   Å   s   rm   c                 C   rg   rh   rm   ri   r   r   r   rk   Ë   rl   c                 C   s0   t | tƒr
|  |¡S t | tƒr| S t| ƒ |¡S r   )r!   r¥   r+   r'   ro   r   r   r   rp   Ó   rq   )ÚlettersÚ	uppercaseÚ	lowercasec                 C   s   t t | ¡ƒ ¡ S r   )rt   ru   rv   rw   rx   r   r   r   rz   Ü   ó   c                 C   s   t  t| ƒ¡S r   )ru   r{   r|   r}   r   r   r   r   ß   rB   c                 C   r�   r‚   r¦   r-   r   r   r   rƒ   â   r„   c                 C   r…   r‚   )r!   r¥   r+   r-   r   r   r   r‡   æ   r„   c                 C   sB   |d u rt  d¡}|j}|d u r|j}~n|d u r|}tdƒ d S )Né   zexec obj in G, L)r   Ú	_getframeÚ	f_globalsÚf_localsrˆ   )ÚobjÚGÚLÚframer   r   r   Úrl_execê   s   
rÀ   z-def rl_reraise(t, v, b=None):
	raise t, v, b
c                  K   r�   r‘   )Ú__builtin__r“   r”   )r•   rÁ   r–   r   r   r   r   r—   ÷   r˜   c                 C   sN   z | st  d¡jd } ddlm} t| |ƒrt| jƒr| W S d W S    Y d S )Nr¸   Ú
__loader__r   )Úzipimporter)r   r¹   rº   Ú	zipimportrÃ   r!   ÚlenÚ_files)ÚldrrÃ   r   r   r   ÚzipImportedü   s    rÈ   ú.ttfc           
      C   s„   ddl m}m}m} ddlm} | ¡ }g }|j}| D ]$}||ƒs"q||ƒD ]}	|||	ƒ}	||	ƒr>|r:|	 ¡  |¡r>||	ƒ q&q|S )Nr   )ÚisfileÚisdirrŸ   )Úlistdir)	Úos.pathrÊ   rË   rŸ   ÚosrÌ   ÚlowerÚappendÚendswith)
ÚdirListÚextrÊ   rË   Ú	path_joinrÌ   ÚRÚAÚDÚfnr   r   r   Ú
_findFiles  s   

"€þrÙ   c                   @   sV   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zddd„Zdd„ Z	dd„ Z
dd„ ZdS )ÚCIDictc                 O   s"   |D ]}|   |¡ q|   |¡ d S r   )Úupdate)r   ry   ÚkwdsÚar   r   r   Ú__init__  s   zCIDict.__init__c                 C   s   |  ¡ D ]\}}|| |< qd S r   )r“   )r   r×   r–   r   r   r   r   rÛ     ó   zCIDict.updatec                 C   s(   z|  ¡ }W n   Y t | ||¡ d S r   )rÏ   rJ   Ú__setitem__©r   r–   r   r   r   r   rà     ó
   zCIDict.__setitem__c                 C   ó"   z|  ¡ }W n   Y t | |¡S r   )rÏ   rJ   Ú__getitem__©r   r–   r   r   r   rä   !  ó
   zCIDict.__getitem__c                 C   rã   r   )rÏ   rJ   Ú__delitem__rå   r   r   r   rç   (  ræ   zCIDict.__delitem__Nc                 C   s"   z| | W S  t y   | Y S w r   )ÚKeyError)r   r–   Údvr   r   r   Úget/  s
   
ÿz
CIDict.getc                 C   s   z| |  W dS    Y dS )NTFr   rå   r   r   r   Ú__contains__5  s
   zCIDict.__contains__c                 G   ó(   z|  ¡ }W n   Y tj| |f| Ž S r   )rÏ   rJ   Úpop©r   r–   rÝ   r   r   r   rí   <  râ   z
CIDict.popc                 G   rì   r   )rÏ   rJ   Ú
setdefaultrî   r   r   r   rï   C  râ   zCIDict.setdefaultr   )r   r   r   rÞ   rÛ   rà   rä   rç   rê   rë   rí   rï   r   r   r   r   rÚ     s    
rÚ   Úmac)ÚoglezBMP )rñ   ÚEPSF)rñ   ÚGIFf)rñ   ÚJPEG)ÚttxtÚPICT)rñ   ÚPNGf)rñ   z.PPM)rñ   ÚTIFF)ÚCAROzPDF )ÚMSIEÚTEXT)ÚBMPÚEPSrò   ÚGIFÚJPGrô   ÚPCTrö   ÚPNGÚPPMÚTIFrø   ÚPDFÚHTMLr  c                 C   sl   z/|d u s|d u r|d urz
t | ¡  \}}W n   Y W d S t | ¡ ||¡ t | ¡ W d S    Y d S r   )Ú_KNOWN_MAC_EXTÚupperÚmacfsÚFSSpecÚSetCreatorTypeÚ
macostoolsÚtouched)ÚfilenameÚcreatorcodeÚfiletyperÓ   r   r   r   Úmarkfilename_  s   r  c                 C   r   r   r   )r  r  r  r   r   r   r  k  ó   )rÇ   z#can't handle compact distro type %rc
                 C   sÀ   ||   d|¡ƒ} || ƒ}
|
||fv rdS |
 |¡r!d| td… fS |
 |¡r.d| td… fS ||ƒ ƒ}t|ƒ}|
 |¡rW| |d…  |¡rOd| ||	 d… fS |t| ƒkrWdS tj | ¡ | fS )z3if the name starts with a known prefix strip it offú/)r¸   rž   r¸   N)ÚreplaceÚ
startswithÚ_archivepfxlenÚ_archivedirpfxlenrÅ   rÎ   ÚpathÚisabs)rØ   Ú_archivepfxÚ_archivedirpfxÚ_archiveÚ_archivedirÚos_path_normpathÚos_path_normcaseÚ	os_getcwdÚos_sepÚ
os_sep_lenÚnfnÚcwdÚnr   r   r   Ú__startswith_rl‡  s   

&r%  c                 C   s   t | ƒd S )Nr¸   )r%  ©rØ   r   r   r   Ú_startswith_rlž  r   r'  c              
   C   s^   t | ƒ\}}||ƒ}|s|g kr-|ttt|fdd„tt||fdd„ttj ¡ ƒƒƒƒƒ7 }|S )Nc                 S   s
   |t | ƒS r   )r  )r_   r×   Úpjoinr   r   r   Ú<lambda>¥  ó   
 zrl_glob.<locals>.<lambda>c                 S   s
   || |ƒS r   r   )r_   ÚpfnÚfnmatchr   r   r   r)  ¥  r*  )r%  rI   Úmapr  ÚfilterÚ__rl_loader__rÆ   Úkeys)ÚpatternÚglobr,  Ú_RL_DIRr(  r   r+  Úrr   r   r   Úrl_glob¡  s
   :r5  c                 C   s   | S r   r   r&  r   r   r   r'  ª  r  c                 C   s   || ƒS r   r   )r1  r2  r   r   r   r5  ¬  r£   ú.pyc                   C   ó   t S )z*return truth if a file system distribution©Ú_isFSDr   r   r   r   ÚisFileSystemDistro±  ó   r:  c                   C   s   t  S )z.return truth if not a file system distributionr8  r   r   r   r   ÚisCompactDistroµ  s   r<  c                   C   r7  )z1return truth if a source file system distribution)Ú_isFSSDr   r   r   r   ÚisSourceDistro¹  r;  r>  c                    s�  dd„ ‰ ‡ fdd„t jD ƒ}|r2t|ƒs|g}ntdt|ƒƒ}|D ]}ˆ |ƒ}||vr1| d|¡ q!|rTddˆ dƒfD ]}||v rR|rItd	| ƒ | |¡ ||v sAq;n
d|vr^| dd¡ |roddl}|j}td
ƒ ||ƒ t j}	zQz|t _i }
t	d|  |
ƒ |
d W W |	t _S  t
y¤   |	t _d|  }|rž|d|  }t|ƒ Y n   t  ¡ }d| |d f }t|ƒ Y W |	t _dS W |	t _dS |	t _w )zEDynamically imports possible packagized module, or raises ImportErrorc                 S   s   t j t j t j | ¡¡¡S r   )rÎ   r  ÚnormcaseÚabspathÚnormpathr^   r   r   r   r)  ¿  ó    z!recursiveImport.<locals>.<lambda>c                    s   g | ]}ˆ |ƒ‘qS r   r   )r›   Úp©Ú	normalizer   r   rœ   À  ó    z#recursiveImport.<locals>.<listcomp>Nr   rž   Ú.zremoved "%s" from pathzpath=zimport %s as mr   zCould not import '%s'z	 under %sz)Exception raised while importing '%s': %sr¸   )r   r  r#   r.  rI   ÚinsertÚprintÚremoveÚpprintrÀ   ÚImportErrorÚannotateExceptionÚexc_info)Ú
modulenameÚbaseDirÚnoCWDÚdebugr  ÚtprC  rK  ÚppÚopathÚNSÚmsgÚer   rD  r   ÚrecursiveImport½  s\   €
þ€ÿ
õ
úrY  c                 C   s   t || jƒS )z/Can call down into e.g. object1.object2[4].attr)ÚevalÚ__dict__)r¼   Únamer   r   r   ÚrecursiveGetAttrí  s   r]  c                 C   sZ   |  d¡}t|ƒdkrt| ||ƒ dS d |dd… ¡}|d }t| |ƒ}t|||ƒ dS )z7Can call down into e.g. object1.object2[4].attr = valuerG  r¸   Néÿÿÿÿ)ÚsplitrÅ   r”   rŸ   r]  )r¼   r\  ÚvalueÚtokensÚmostÚlastÚparentr   r   r   ÚrecursiveSetAttrñ  s   

re  c                  C   sF   zdd l } W | S  ty"   d } ddlm} |rtdƒ Y | S Y | S w )Nr   )ÚZLIB_WARNINGSzzlib not available)ÚzlibrL  Úreportlab.rl_configrf  r   )rg  rf  r   r   r   Úimport_zlibý  s   
üÿüri  é   Újavar¸   )ÚImagec                   @   ó   e Zd ZdZdd„ ZdS )ÚArgvDictValuezGA type to allow clients of getArgvDict to specify a conversion functionc                 C   ó   || _ || _d S r   )r`  Úfunc)r   r`  rp  r   r   r   rÞ     ó   
zArgvDictValue.__init__N)r   r   r   Ú__doc__rÞ   r   r   r   r   rn    ó    rn  c                  K   s¸   dd„ }t jdd… }i }|  ¡ D ]H\}}t|tƒr"|j|j}}nd}d}|d }|D ]"}	|	 |¡dkrN|	t|ƒd… }
| 	|	¡ |||
|ƒ||< d} nq,|sY||||ƒ||< q|S )zæ Builds a dictionary from its keyword arguments with overrides from sys.argv.
        Attempts to be smart about conversions, but the value can be an instance
        of ArgDictValue to allow specifying a conversion function.
    c                 S   s”   |r||ƒ} | S t | ƒr|} | S t| tƒrt|ƒ} | S t| tƒr&t|ƒ} | S t| tƒr3tt|ƒƒ} | S t| tƒr@tt|ƒƒ} | S td|t| ƒf ƒ‚)NzCan't convert string %r to %s)	rA   r!   rF   rG   rI   rZ  rH   Ú	TypeErrorr   )r   Úavrp  r   r   r   ÚhandleValue&  s&   ô
ö	
ø
ú
üÿz getArgvDict.<locals>.handleValuer¸   Nr   ú=)
r   Úargvr“   r!   rn  r`  rp  ÚfindrÅ   rJ  )Úkwrv  rÖ   rÕ   r–   r   rp  ÚhandledÚkerÝ   ru  r   r   r   ÚgetArgvDict!  s(   

û€r}  c              
   C   sj   zddl m} | d u rtj tj t¡d¡} || ƒW S  ty4 } zt|ƒdkr)‚ W Y d }~d S d }~ww )Nr   )ÚHyphenzhyphen.mashedzNo module named pyHnj)	Úreportlab.lib.pyHnjr~  rÎ   r  rŸ   ÚdirnameÚ__file__rL  r'   )ÚhDictr~  ÚerrMsgr   r   r   ÚgetHyphenaterM  s   
€þr„  c                 C   sN   z| j j}| d¡}|dkr||d d… W S |W S  ty&   t| ƒ Y S w )zReturn a shortened class namerG  r   r¸   N)r²   r   ÚrfindÚAttributeErrorr'   )r   r\  r?   r   r   r   Ú
_classNameV  s   
ÿr‡  rŽ   c                 C   sx   d|vrd| }zt | |ƒW S  ty;   tstd u r‚ t| ƒ} t | ¡}d|vr5tjdkr5| tjd¡}t	|ƒ Y S w )Nr4  rŽ   Ú
)
ÚopenÚIOErrorr9  r/  r'  Úget_datarÎ   Úlinesepr  rk   )r\  Úmoder.   r   r   r   Úopen_for_read_by_name`  s   
 ùrŽ  c                 C   s   || ƒ  ¡ S r   )Úread)ÚurlÚopenerr   r   r   Ú
datareaderp  r   r’  )Úurlopen)Úunquotec                 C   s¦   z
|   dd¡\}}W n ty   tddƒ‚w |sd}| d¡}|dkr;d||d	… vr;||d d	… }|d	|… }nd
}|dkrJ|| d¡ƒ}|S ||ƒ d¡}|S )zUse "data" URL.ú,r¸   z
data errorzbad data URLztext/plain;charset=US-ASCIIú;r   rw  Nrž   Úbase64Úasciizlatin-1)r_  Ú
ValueErrorrŠ  r…  r+   )r�  r”  ÚdecodebytesÚtypÚdataÚsemiÚencodingr   r   r   r’  z  s"   	
ÿ
ÿc              	   C   sh   t | dƒr| S zt| |ƒW S    zt| dd…  ¡ dkr!|| ƒn|| ƒ ¡ ƒW  Y S    td|  ƒ‚)z)attempt to open a file or URL for readingr�  Né   zdata:zCannot open resource "%s")r³   rŽ  rk   rÏ   r�  rŠ  )r\  r�  r“  r’  r   r   r   Úopen_for_read—  s   2r   c                 C   sT   t | |ƒ}| |ur&t|dƒr&|� | ¡ W  d   ƒ S 1 sw   Y  d S | ¡ S )NÚ__exit__)r   r³   r�  )r\  r�  Úfr   r   r   Úopen_and_read£  s   
$ÿr£  r�   c                 C   s   t | |ƒ d¡S ©Nrˆ  )r£  r_  )r\  r�  r   r   r   Úopen_and_readlines«  r   r¥  c                 C   sD   t | dƒrdS || ƒrdS tstd u rdS t| ƒ} | ttj ¡ ƒv S )Nr�  TF)r³   r9  r/  r'  rI   rÆ   r0  )rØ   Úos_path_isfiler   r   r   Ú	rl_isfile®  s
   r§  c                 C   sf   || ƒrdS t std u rdS t|| ƒƒ} |  tj¡s| tj7 } ttt| fdd„ttj	 
¡ ƒƒƒƒdkS )NTFc                 S   s
   |   |¡S r   )r  )r_   Úpnr   r   r   r)  º  r*  zrl_isdir.<locals>.<lambda>r   )r9  r/  r'  rÑ   rÎ   ÚseprÅ   rI   r.  rÆ   r0  )r¨  Úos_path_isdirr  r   r   r   Úrl_isdirµ  s
   (r«  c                    sV   |ˆ ƒs
t s
td u r|ˆ ƒS t|ˆ ƒƒ‰ ˆ  tj¡sˆ tj7 ‰ ‡ fdd„tj ¡ D ƒS )Nc                    s&   g | ]}|  ˆ ¡r|tˆ ƒd … ‘qS r   )r  rÅ   rš   ©r¨  r   r   rœ   À  s   & zrl_listdir.<locals>.<listcomp>)r9  r/  r'  rÑ   rÎ   r©  rÆ   r0  )r¨  rª  r  Ú
os_listdirr   r¬  r   Ú
rl_listdir¼  s   r®  c           	   
   C   s¬   || ƒs
t s
td u r|| ƒS t|| ƒƒ}ztj| }W n ty(   || ƒ Y S w |d }|d }||d? d@ d |d? d@ |d@ |d? d@ |d? d	@ |d@ d
> dddf	ƒS )NrŸ  é   é	   é   i¼  é   é   é   é?   r¸   r   )r9  r/  r'  rÆ   rè   )	r¨  r¦  r  Úos_path_getmtimeÚtime_mktimerC  rX  r.   Údr   r   r   Úrl_getmtimeÂ  s   ÿJr¹  é   )é   rj  )Úutilc                 C   sJ   dD ]}t j || | ¡}t j |¡r t | |¡}|j ¡   S qtdƒ‚)N)r6  z.pywz.pyoz.pycz.pydzno suitable file found)	rÎ   r  rŸ   rÊ   Úimportlib_utilÚspec_from_file_locationÚloaderÚload_modulerL  )r\  ÚdirrÓ   r  Úspecr   r   r   Ú__rl_get_module__Ï  s   þrÃ  c                 C   sF   t  | |g¡\}}}zt  | |||¡W |r| ¡  S S |r"| ¡  w w r   )ÚimpÚfind_modulerÀ  Úclose)r\  rÁ  r¢  rC  Údescr   r   r   rÃ  Ø  s   
ÿ
ÿc              
   C   sÔ   | t jv rt j|  }t j| = nd }zPzt| |ƒW W |r!|t j| < S S    tƒ rZdd l}t|ƒ}|dks7| r9tpDtj 	t| 
dtj¡¡}| |¡}| | ¡ Y W |rY|t j| < S S td| |f ƒ‚|ri|t j| < w )Nr   rG  r  z%s[%s])r   ÚmodulesrÃ  r<  rÄ   r'  r  rÎ   r  rŸ   r  r©  rÃ   rÀ  rL  )r\  rÁ  ÚomrÄ   Úzir   r   r   Úrl_get_moduleà  s$   


ö*
þrË  c                 C   s$   zt | tjƒW S  ty   Y dS w r‘   )r!   rl  r†  )Úimr   r   r   Ú_isPILImageõ  s
   ÿrÍ  c                   @   s^   e Zd ZdZi Zddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚImageReaderz4Wraps up either PIL or Java to get data from bitmapsNc                 C   s"  t |tƒr|j| _d S || _|| _d | _d | _d | _d | _d | _	t
|ƒrH|| _t|dd ƒ| _z| jj| _W d S  tyG   dt| ƒ | _Y d S w z¸ddlm} t|dƒ| _t | jtƒr]d}|dkr˜| j ¡ }|d@ rvz| j ¡  W n   Y |d@ r’| js‰ddlm} || jjƒ | j t|ƒ|¡}t|ƒ| _n|d	kr«t |tƒr«| j ¡  | `t| _trÊ| js·|   | j¡| _t| jd
d ƒdkrÇ| j!| _"W d S W d S ddl#m$} z|| jƒ\| _| _}W n   t%d||  &¡ f ƒ Y | j!| _"| j ¡ | _	d | _'| j (d¡ W d S    t%d||  &¡ f ƒ Y d S )NÚfpzPILIMAGE_%dr   )ÚimageReaderFlagsrŽ   rº  rj  )Úregister_resetr^  Úformatrô   )ÚreadJPEGInfoz[
Imaging Library not available, unable to import bitmaps only jpegs
fileName=%r identity=%sz
fileName=%r identity=%s))r!   rÎ  r[  Ú_identÚfileNameÚ_imageÚ_widthÚ_heightÚ_transparentÚ_datarÍ  ÚgetattrrÏ  r†  Úidrh  rÐ  r   Ú_bytesIOTyper�  rÆ  Ú_cacheÚ	rl_configrÑ  Úclearrï   r/   rk   r'   ÚLazyImageReaderr²   Ú
haveImagesÚ_read_imageÚ_jpeg_fhÚjpeg_fhÚreportlab.pdfbase.pdfutilsrÓ  rM  ÚidentityÚ_dataAÚseek)r   rÕ  ÚidentrÐ  rœ  rÑ  rÓ  r   r   r   r   rÞ   þ  sl   
ÿ

&zImageReader.__init__c                 C   s\   | j }t|ƒstt| ddƒddƒ}| j}d| jjtt| ƒƒ|r#d| p$d|r*d| p+df S )z9try to return information that will identify the instancerÏ  Nr\  z[%s@%s%s%s]z	 ident=%rrž   z filename=%r)rÕ  rA   rÛ  rÔ  r²   r   ÚhexrÜ  )r   rØ   rê  r   r   r   rç  ;  s
   4zImageReader.identityc                 C   s2   t jdd… dkrddlm} | |¡S t |¡S )Nr   rj  rk  )ÚImageIO)r   ÚplatformÚjavax.imageiorì  r�  rl  r‰  )r   rÏ  rì  r   r   r   rã  C  s   

zImageReader._read_imagec                 C   s   | j }| d¡ |S r‘   )rÏ  ré  )r   rÏ  r   r   r   rä  J  s   
zImageReader._jpeg_fhc                 C   r   r   r   r   r   r   r   rå  O  r  zImageReader.jpeg_fhc                 C   s\   | j d u s
| jd u r(tjdd… dkr | j ¡ | _ | j ¡ | _n| jj\| _ | _| j | jfS )Nr   rj  rk  )r×  rØ  r   rí  rÖ  ÚgetWidthÚ	getHeightÚsizer   r   r   r   ÚgetSizeR  s   zImageReader.getSizec              	   C   sð  zé| j du ræd| _tjdd… dkruddl}ddlm} |  ¡ \}}| || d¡}|| j	dd|||d|ƒ}| 
¡  g }|j}tt|ƒƒD ]"}	||	 }
|t|
d? d@ ƒƒ |t|
d	? d@ ƒƒ |t|
d@ ƒƒ qEd
 |¡| _ d| _| j W S | j	}|j }| _|dv rªtj d¡rŒ| ¡  t| ¡ |dkr–dnd ƒ| _|dd… }| |¡}|| _n/|dvrÙ|jdkrÑ|jdkrÑd|jv rÑ| d¡}t| ¡ d ƒ| _| d¡}n| d¡}d| _t|dƒrá|jn|jƒ | _ | j W S    td|  ¡  ƒ Y dS )z'Return byte array of RGB data as stringNr   rj  rk  )ÚPixelGrabberr?   é   éÿ   é   rž   ÚRGB)ÚLAÚRGBAz1.1.7rù  r»  r¸   r^  )r¾   r÷  ÚCMYKr  ÚPÚtransparencyÚtobytesz
identity=%s)rÚ  rè  r   rí  ÚjarrayÚjava.awt.imageró  rò  ÚzerosrÖ  Ú
grabPixelsrÐ   ÚrangerÅ   ÚchrrŸ   r�  rl  ÚVERSIONr  ÚloadrÎ  r_  ÚconvertrÒ  Úinfor³   rý  ÚtostringrM  rç  )r   rþ  ró  ÚwidthÚheightrª   ÚpgÚpixelsrÝ   r?   ÚrgbrÌ  r�  Únmr   r   r   Ú
getRGBData[  sN   
ï


zImageReader.getRGBDatac                 C   s   |   ¡ \}}|||  ¡ fS r   )rò  r  )r   r	  r
  r   r   r   ÚgetImageDataˆ  s   zImageReader.getImageDatac              	   C   sš   t jdd… dkrd S d| jjv rK| jjd d }| jj}z|j}W n   z|j}W n   Y Y d S Y tr>|||d … S dd„ |||d … D ƒS d S )Nr   rj  rk  rü  r»  c                 S   s   g | ]}t |ƒ‘qS r   r™   )r›   r   r   r   r   rœ   �  rF  z.ImageReader.getTransparent.<locals>.<listcomp>)r   rí  rÖ  r  Úpaletterœ  r   )r   rü  r  r   r   r   ÚgetTransparentŒ  s"   

þzImageReader.getTransparentr   )r   r   r   rr  rÞ  rÞ   rç  rã  rä  rå  rò  r  r  r  r   r   r   r   rÎ  û  s    
=	-rÎ  c                   @   s,   e Zd Zdd„ ZeeƒZdd„ ZeeƒZdS )rá  c                 C   s   t | jdƒS )NrŽ   )r   rÕ  r   r   r   r   rÏ  ¢  r   zLazyImageReader.fpc                 C   s   |   | j¡S r   )rã  rÏ  r   r   r   r   rÖ  ¦  r   zLazyImageReader._imageN)r   r   r   rÏ  ÚpropertyrÖ  r   r   r   r   rá  ¡  s
    rá  c                 C   s*   z|   ¡ W S  ty   t| ƒ  ¡  Y S w )zAGet width, height and RGB pixels from image file.  Wraps Java/PIL)r  r†  rÎ  )ÚimageFileNamer   r   r   r  ª  s
   
ÿr  c                   @   sÐ   e Zd ZdZd4dd„Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zeeeed)œZd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ ZdS )5Ú	DebugMemoaÅ  Intended as a simple report back encapsulator

    Typical usages:
        
    1. To record error data::
        
        dbg = DebugMemo(fn='dbgmemo.dbg',myVar=value)
        dbg.add(anotherPayload='aaaa',andagain='bbb')
        dbg.dump()

    2. To show the recorded info::
        
        dbg = DebugMemo(fn='dbgmemo.dbg',mode='r')
        dbg.load()
        dbg.show()

    3. To re-use recorded information::
        
        dbg = DebugMemo(fn='dbgmemo.dbg',mode='r')
            dbg.load()
        myTestFunc(dbg.payload('myVar'),dbg.payload('andagain'))

    In addition to the payload variables the dump records many useful bits
    of information which are also printed in the show() method.
    úrl_dbgmemo.dbgÚwr¸   r   Nc              
      s   dd l }dd l}	|| _|stj| _nt|dƒr|| _nt|dƒ| _|dkr'd S i  | _}
|rGt ¡ dkrGdd l	}t
ƒ }| d |¡ | ¡ |
d< t ¡ }t |¡}tj |¡}|r]t |¡p^d}tj tj tjd ¡¡}d}d }zdd l}| t d¡¡}|d }W n   Y tj‰ tˆ  ¡ ƒ}| ¡  |
 i d	| | |  ¡ ¡¡“d
tj“dtj “dt!tj"ƒ“dtj#“dtj$“dtj%“dtj“dtj“d|“d|	 &¡ “d|“d|“dtj'“dt(tddƒ“dt(tddƒ“dt(tddƒ“t(tddƒd )dg‡ fdd „|D ƒ ¡t*tƒ||d!œ¥¡ td"ftd#ffD ]#\}}|D ]}t||ƒ�r0zt(||ƒƒ |
|< W �q   Y �q�q�q||k�rKz|
 |t |¡d$œ¡ W n   Y |�rptj tjd ¡}tj +|¡�rpz|t|d%ƒ ,¡ f|
d&< W n   Y i }tj- .¡ D ]H\}‰|d'k�s—|d(k�s—|d d)… d*k�s—|d d+… d,k�r¾‡fd-d „d.D ƒ}d/d „ |D ƒ�r¾|d gd0d „ |d1d … D ƒ }t/|ƒ||< �qw||
d2< i | jd3< |  0|¡ d S )4Nr   Úwriter  )NNNÚ__tracebackz???zmeta_data.marÚproject_versionÚgmtrí  ÚversionÚ
hexversionÚ
executableÚexec_prefixÚprefixr  rx  r#  ÚhostnameÚlcwdÚlpcwdÚ	byteorderÚmaxintÚ
maxunicodez????Úapi_versionÚversion_infoÚwinverz
			rž   c                    s   g | ]
}d |ˆ | f ‘qS )ú%s=%rr   )r›   r–   )Úenvr   r   rœ   þ  rB  z&DebugMemo.__init__.<locals>.<listcomp>)r)  Úenvironmentr/  Úproject_meta_datar  )ÚgetwindowsversionÚgetfilesystemencoding)ÚunameÚctermidÚgetgidÚgetuidÚgetegidÚgeteuidÚgetloginÚ	getgroupsÚgetpgrpÚgetpidÚgetppid)ÚexedÚlexedr4  Ú__scriptÚ	reportlabÚrlextraé
   z
reportlab.rö  zrlextra.c                    s   g | ]}t ˆ |d ƒ‘qS r   )rÛ  rš   )r   r   r   rœ     r�   )Ú__version__Ú__path__r�  c                 S   ó   g | ]}|r|‘qS r   r   ©r›   Ú_fr   r   r   rœ     rF  c                 S   rC  r   r   rD  r   r   r   rœ      rF  r¸   Ú__module_versionsÚ	__payload)1ÚtimeÚsocketrØ   r   Ústdoutr³   r‰  ÚstorerN  Ú	tracebackrk   Ú	print_excÚgetvaluerÎ   ÚgetcwdrÌ   r  r€  r@  rx  Úmarshalr{   r/  r‹  ÚenvironrI   r0  ÚsortrÛ   ÚasctimeÚgmtimerí  r  rë  r  r  r  r   Úgethostnamer$  rÛ  rŸ   ÚreprrÊ   r�  rÈ  r“   rH   Ú_add)r   rØ   r�  Ú	getScriptrÈ  Úcapture_tracebackrJ  rz  rH  rI  rK  rL  r.   r#  r"  Úpcwdr#  r;  r  ÚmdrP  ÚKÚMrÖ   rÝ   Úmodule_versionsr$  r   r   )r+  r   r   rÞ   Ë  sÎ   



ÿþ
ýüûúùø	÷
öõôóòñð

ëþüÿ
8 €
zDebugMemo.__init__c                 C   s(   | j d }| ¡ D ]\}}|||< q	d S ©NrG  )rK  r“   )r   r×   Úpayloadr–   r   r   r   r   rW  &  s   

ÿzDebugMemo._addc                 K   s   |   |¡ d S r   )rW  )r   rz  r   r   r   Úadd+  rB   zDebugMemo.addc              
   C   sŽ   z|  ¡ }t | j|¡ W d S    | j ¡ }tƒ }| ¡ D ]\}}z
t ||i|¡ W q   d| ||< Y q| |d¡ t ||¡ Y d S )Nz<unpicklable object %r>r   )Útellru   ÚdumprK  Úcopyrk   r“   ré  )r   r¢  ÚposÚSÚffr–   r   r   r   r   Ú_dump.  s   
zDebugMemo._dumpc                 C   ó0   t | jdƒ}z|  |¡ W | ¡  d S | ¡  w )NÚwb)r‰  rØ   rh  rÆ  ©r   r¢  r   r   r   rc  =  ó   zDebugMemo.dumpc                 C   s   t ƒ }|  |¡ | ¡ S r   )rk   rh  rN  rk  r   r   r   rv   D  s   
zDebugMemo.dumpsc                 C   s   t  |¡| _d S r   )ru   r  rK  rk  r   r   r   Ú_loadI  r   zDebugMemo._loadc                 C   ri  )NÚrb)r‰  rØ   rm  rÆ  rk  r   r   r   r  L  rl  zDebugMemo.loadc                 C   s   |   t|ƒ¡ d S r   )rm  rk   )r   r.   r   r   r   r{   S  r·   zDebugMemo.loadsc                 C   s¦   |   |dd … ¡ t| ¡ ƒ}| ¡  |D ];}||  }}t|tƒr&|d }zt|ƒ tj| }t	|dd ƒ|kr:dp;d}W n   d }d}Y |   d|||f ¡ qd S )Nrº  r   rA  ÚSAMEÚ	DIFFERENTz??????unknown??????z  %s = %s (%s))
Ú_writelnrI   r0  rR  r!   rH   Ú
__import__r   rÈ  rÛ  )r   r–   r   r\  ÚvkÚvk0r   r¸  r   r   r   Ú_show_module_versionsV  s   
özDebugMemo._show_module_versionsc                 C   s   |   d||dd … f ¡ d S )Nz*###################%s %s##################rº  )rq  )r   r–   Úwhatr   r   r   Ú_bannerf  rß   zDebugMemo._bannerc                 C   ó   |   |d¡ d S )NzStart  ©rw  rå   r   r   r   Ú_starti  r   zDebugMemo._startc                 C   rx  )NzFinish ry  rå   r   r   r   Ú_finishl  r   zDebugMemo._finishc                 C   s"   |   |¡ |  |¡ |  |¡ d S r   )rz  rq  r{  rá   r   r   r   Ú_show_lineso  s   

zDebugMemo._show_linesc                 C   s,   d|t j |d ¡f }|  ||d ¡ d S )Nz%s %sr   r¸   )rÎ   r  Úbasenamer|  rá   r   r   r   Ú
_show_filet  s   zDebugMemo._show_filec                 C   s6   |rdd l }|  |¡ |  || j¡ |  |¡ d S d S r‘   )rK  rz  rJ  r{  )r   r–   r   rK  r   r   r   Ú_show_payloadx  s   
üzDebugMemo._show_payloadc                 C   sˆ   dD ]?}z)|gj }t|ƒ tj| }||jƒ dD ]}t||ƒr+|d|t||ƒf ƒ qW n   |dƒ Y |  dd |j	¡ ¡ qd S )N)Ú	_rl_accelÚ	_renderPMÚsgmlopÚpyRXPÚpyRXPUÚ_imagingrl  )rA  r  Ú_versionr  r*  z	not foundú )
rÐ   rr  r   rÈ  r�  r³   rÛ  rq  rŸ   Ú__self__)r   ÚmnrÖ   r   Úvnr   r   r   Ú_show_extensions  s   


€þ
õzDebugMemo._show_extensions)rF  rG  r  r=  c                 C   sŠ   t | j ¡ ƒ}| ¡  |D ]}|t | j ¡ ƒvr$|  d|| j| f ¡ q|D ]}|t | j ¡ ƒv r>| j| | || j| ƒ q'|  ¡  d S )Nz
%-15s = %s)rI   rK  r0  rR  Úspecialsrq  r‹  )r   r\  r–   r   r   r   Úshow’  s   *€*€zDebugMemo.showc                 C   ó   | j d | S r_  ©rK  ©r   r\  r   r   r   r`  ›  rB   zDebugMemo.payloadc                 C   s   || j d |< d S r_  r�  )r   r\  r`  r   r   r   rà   ž  r·   zDebugMemo.__setitem__c                 C   rŽ  r_  r�  r�  r   r   r   rä   ¡  rB   zDebugMemo.__getitem__c                 C   s   | j  |d ¡ d S r¤  )rJ  r  )r   rW  r   r   r   rq  ¤  r€   zDebugMemo._writeln)r  r  r¸   r   r¸   N)r   r   r   rr  rÞ   rW  ra  rh  rc  rv   rm  r  r{   ru  rw  rz  r{  r|  r~  r  r‹  rŒ  r�  r`  rà   rä   rq  r   r   r   r   r  ±  s:    
[ý	r  c                 C   s*   | D ]}t |ƒrt||ƒ q||ƒ qd S r   )r#   Ú_flatten)r¾   rÝ   r_   r   r   r   r‘  §  s   
þr‘  c                 C   s   g }t | |jƒ |S )z'recursively flatten the list or tuple L)r‘  rÐ   )r¾   rÕ   r   r   r   Úflatten¬  s   r’  c                 C   s$   	 | t  |¡jƒ}|r|S |d7 }q)zPapply func to the locals at each stack frame till func returns a non false valuer¸   )r   r¹   r»   )rp  ÚdepthÚ_r   r   r   Úfind_locals²  s
   ýr•  c                   @   s   e Zd Zdd„ Zdd„ ZdS )Ú_FmtSelfDictc                 C   ro  r   )r¼   Ú_overrideArgs)r   r¼   ÚoverrideArgsr   r   r   rÞ   º  rq  z_FmtSelfDict.__init__c                 C   sR   z| j | W S  ty(   z	| jj| W  Y S  ty'   t| j|ƒ Y  Y S w w r   )r—  rè   r¼   r[  rÛ  rå   r   r   r   rä   ½  s   ÿýz_FmtSelfDict.__getitem__N)r   r   r   rÞ   rä   r   r   r   r   r–  ¹  s    r–  c                   @   rm  )ÚFmtSelfDictz mixin to provide the _fmt methodc                 K   s   t | |ƒ}|| S r   )r–  )r   Úfmtr˜  r×   r   r   r   Ú_fmtÈ  s   
zFmtSelfDict._fmtN)r   r   r   rr  r›  r   r   r   r   r™  Æ  rs  r™  c           	      C   s’   g }|dƒ}g }| }|   ¡ D ]+}||ƒ}|| | |ks!|g kr-| |¡ || | }q| d |¡¡ |g}|}q|g krG| d |¡¡ |S )Nr‡  )r_  rÐ   rŸ   )	ÚtxtÚmWÚSWr¾   ÚwsÚOr  r�   Últr   r   r   Ú_simpleSplitÌ  s   
r¢  c                    sX   ddl m‰  t| ƒ d¡}||f‡ fdd„	}|r*g }|D ]}| t|||ƒ¡ q|}|S )Nr   ©ÚstringWidthrˆ  c                    s   ˆ | ||ƒS r   r   )ÚtextÚfNÚfSr£  r   r   r)  à  s    zsimpleSplit.<locals>.<lambda>)Úreportlab.pdfbase.pdfmetricsr¤  r8   r_  Úextendr¢  )r¥  ÚfontNameÚfontSizeÚmaxWidthÚlinesrž  r¾   Úlr   r£  r   ÚsimpleSplitÝ  s   r¯  c                 C   sZ   ddl m} | du r| S t| ƒr|  d¡}|| ƒ} |  dd¡} |  dd¡} |  d	d
¡} | S )zEscapes once onlyr   )ÚescapeNr)   ú	&amp;amp;ú&amp;ú&amp;gt;ú&gt;ú&amp;lt;ú&lt;)Úxml.sax.saxutilsr°  r*   r7   r  )r¥  r°  r.   r   r   r   ÚescapeTextOnceè  s   r¸  c                 C   s<   t | ƒr| S tD ]}z|  |¡W   S    Y qtd|  ƒ‚)Nz(cannot convert %r to filesystem encoding)rC   ÚfsEncodingsr7   r™  )rØ   r3   r   r   r   ÚfileName2FSEncõ  s   rº  c                 C   sR   ddl m} t| ƒrt| ƒS |D ]}z|  |¡ d¡W   S    Y qtd|  ƒ‚)z%attempt to convert a filename to utf8r   )r¹  r)   z,cannot convert %r to utf8 for file path name)rh  r¹  rC   r4   r7   r+   r™  )rØ   r¹  r3   r   r   r   rº     s   c                 C   s`   t  dg| dg¡}t  |d¡\}}}z||ƒ ||ƒ ||ƒ W n	 ty)   Y nw t|||ƒS )a¸  
    Loop over a collection with look-ahead and look-back.
    
    From Thomas Guest, 
    http://wordaligned.org/articles/zippy-triples-served-with-python
    
    Seriously useful looping tool (Google "zippy triples")
    lets you loop a collection and see the previous and next items,
    which get set to None at the ends.
    
    To be used in layout algorithms where one wants a peek at the
    next item coming down the pipe.

    Nr»  )Ú	itertoolsÚchainÚteeÚStopIterationÚzip)r“   r©  ÚprevÚthisÚnextr   r   r   Úprev_this_next  s   ÿrÃ  c                 C   sÊ   t | ƒr	|  d¡} t| ƒd }| d7 } d}dg}||kr[| | dkrI| |d  dkr7|d  d7  < |d7 }n|d  ¡ |d< ||krH| d¡ n
|d  | | 7  < |d7 }||ks|d  ¡ |d< |S )a  
    Splits the string s at every unescaped comma and returns the result as a list.
    To escape a comma, double it. Individual items are stripped.
    To avoid the ambiguity of 3 successive commas to denote a comma at the beginning
    or end of an item, add a space between the item seperator and the escaped comma.
    
    >>> commasplit(u'a,b,c') == [u'a', u'b', u'c']
    True
    >>> commasplit('a,, , b , c    ') == [u'a,', u'b', u'c']
    True
    >>> commasplit(u'a, ,,b, c') == [u'a', u',b', u'c']
    r)   r¸   r‡  r   rž   r•  r^  )r*   r7   rÅ   rw   rÐ   )r.   r$  r?   r4  r   r   r   Ú
commasplit(  s$   
€örÄ  c                 C   s   d  dd„ | D ƒ¡S )a‘  
    Inverse of commasplit, except that whitespace around items is not conserved.
    Adds more whitespace than needed for simplicity and performance.
    
    >>> commasplit(commajoin(['a', 'b', 'c'])) == [u'a', u'b', u'c']
    True
    >>> commasplit((commajoin([u'a,', u' b ', u'c'])) == [u'a,', u'b', u'c']
    True
    >>> commasplit((commajoin([u'a ', u',b', u'c'])) == [u'a', u',b', u'c'] 
    r•  c                 S   s$   g | ]}d t |ƒ dd¡ d  ‘qS )r‡  r•  z,,)r8   r  )r›   r?   r   r   r   rœ   S  s   $ zcommajoin.<locals>.<listcomp>)rŸ   )r®  r   r   r   Ú	commajoinH  s   rÅ  Tc                 C   sp   |rt jjp	t jj}|| ƒr| S t jj}t j | ¡s,|D ]}||| ƒ}||ƒr+|  S q|r6td| |f ƒ‚| S )z*search for relative files in likely placeszcannot locate %r with paths=%r)rÎ   r  rÊ   rË   rŸ   r  r™  )rØ   ÚpathsrÊ   ÚfailÚexistsr(  rC  r+  r   r   r   ÚfindInPathsU  s   
ÿrÉ  c           	      C   sø   | s‚ t  ¡ \}}}t|dƒs‚ d}t|jƒ}t|ƒD ]\}}t|tƒr(|} nq|dkrjtsKt	|ƒr=t	| ƒs<|  
|¡} nt	| ƒrG|  |¡} nt| ƒ} t|tƒrat|ddƒra| d t|jƒ |_n||  | 7  < n| | ¡ t|ƒ|_t|||ƒ dS )z,add msg to the args of an existing exceptionry   r^  r   ÚstrerrorNrˆ  )r   rN  r³   rI   ry   Ú	enumerater!   r'   r   rC   r7   r+   rŠ  rÛ  rÊ  rÐ   rH   r�   )	rW  r3   r�   r   rŽ   rX  rÖ   r?   rÝ   r   r   r   rM  b  s2   

þ
€

rM  c                 C   sd   |   dd¡} |   dd¡} |   dd¡} |   dd¡} |   dd	¡} |   dd¡} |   dd¡} |   dd¡} | S )
zÔEnsure XML output is escaped just once, irrespective of input

    >>> escapeOnce('A & B')
    'A &amp; B'
    >>> escapeOnce('C &amp; D')
    'C &amp; D'
    >>> escapeOnce('E &amp;amp; F')
    'E &amp; F'

    ú&r²  r±  r³  r´  rµ  r¶  z&amp;#z&#)r  )rœ  r   r   r   Ú
escapeOnce€  s   rÍ  c                   @   rm  )ÚIdentStrz,useful for identifying things that get splitc                 C   sZ   t |tƒr|j}|d dtt|ƒƒ  … }|d7 }nd}|d| 7 }t | |¡}||_|S )Nrº  r¸   r   z[%d])r!   rÎ  Ú_IdentStr__incrÅ   r'   Ú__new__)Úclsr`  Úincr   r   r   r   rÐ  �  s   

zIdentStr.__new__N©r   r   r   rr  rÐ  r   r   r   r   rÎ  ›  rs  rÎ  c                   @   rm  )ÚRLStringzÚallows specification of extra properties of a string using a dictionary of extra attributes
    eg fontName = RLString('proxima-nova-bold',
                    svgAttrs=dict(family='"proxima-nova"',weight='bold'))
    c                 K   s.   t  | |¡}| ¡ D ]
\}}t|||ƒ q
|S r   )r'   rÐ  r“   r”   )rÑ  r   rÜ   r   r–   r   r   r   rÐ  ®  s   zRLString.__new__NrÓ  r   r   r   r   rÔ  ©  s    rÔ  c                 C   s   t | ƒs	|  d¡} | S )zEforce filename strings to unicode so python can handle encoding stuffr)   )rC   r7   r-   r   r   r   ÚmakeFileName´  s   
rÕ  c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚFixedOffsetTZz&Fixed offset in minutes east from UTC.c                 C   s   t j||d�| _|| _d S )N)ÚhoursÚminutes)ÚdatetimeÚ	timedeltaÚ_FixedOffsetTZ__offsetÚ_FixedOffsetTZ__name)r   Úhr   r\  r   r   r   rÞ   ½  s   
zFixedOffsetTZ.__init__c                 C   ó   | j S r   )rÛ  ©r   Údtr   r   r   Ú	utcoffsetÁ  ó   zFixedOffsetTZ.utcoffsetc                 C   rÞ  r   )rÜ  rß  r   r   r   ÚtznameÄ  râ  zFixedOffsetTZ.tznamec                 C   s
   t  d¡S r‘   )rÙ  rÚ  rß  r   r   r   ÚdstÇ  r$   zFixedOffsetTZ.dstN)r   r   r   rr  rÞ   rá  rã  rä  r   r   r   r   rÖ  º  s    rÖ  c                   @   s.   e Zd Zddd„Zedd„ ƒZedd„ ƒZdS )	Ú	TimeStampNc                 C   s¾   |d u r
ddl m} tj dd¡ ¡ }|s|r,|rt|ƒnd}t |¡}d }}d| _	nt ¡ }t
t |¡ƒ}ttjd ƒ}tjd d	 }d| _	|| _|| _t
|ƒd d
… | _|| _|| _d S )Nr   )Ú	invariantÚSOURCE_DATE_EPOCHrž   g   À¡6ÌAÚUTCg      ¬@i  é<   r¯  )rh  ræ  rÎ   rQ  rê   rw   rG   rH  rT  rã  rH   Ú	localtimeÚtimezoner�   r¡  ÚYMDhmsÚdhhÚdmm)r   ræ  r�   r¡  rí  rî  r   r   r   rÞ   Ë  s$   

zTimeStamp.__init__c                 C   s.   | j rtj | jt| j| j| j ƒ¡S tj ¡ S r   )rã  rÙ  Úfromtimestampr�   rÖ  rí  rî  Únowr   r   r   r   rÙ  à  s   
zTimeStamp.datetimec                 C   s8   t  | j¡}ts| ¡ }|d  d¡|d< d |¡}|S )Nrº  Ú0r‡  )rH  rS  r¡  r   r_  ÚlstriprŸ   )r   rÝ   r   r   r   rS  ç  s   
zTimeStamp.asctimer   )r   r   r   rÞ   r  rÙ  rS  r   r   r   r   rå  Ê  s    

rå  )r)   r   )NN)rÉ   )NNr  )Nr   r   )rŽ   )r�   )r   )TF)ËrA  rr  rÎ   r   rH  rO   rÙ  r—  r   r|   r   rt   r>  r   Úreportlab.lib.loggerr   Úreportlab.lib.rltempfiler   r   r   ÚcPickleru   rL  Úhashlibr	   rí  Úpython_implementationÚisPyPyr   r   r   r   r   r    rH   rI   r#   r(   rN   r1   ÚbytesTr'   ÚunicodeTÚstrTypesr/   r4   r8   r:   r>   r  r¢   r@   rA   r*   rC   rE   r`   ra   Ústringrb   rc   rd   Úiore   rf   rk   rÝ  rn   rp   rz   r   rƒ   r‡   r’   rÛ  rÀ   rŠ   r�   r—   r¥   r¤   r  r´   rµ   r¶   r‰   rÈ   rÙ   rJ   rÚ   r\  r  r  r  r  r  r€  r�  Ú__RL_DIRr  r@  r3  rx  r2  r,  rÂ   r/  r9  ÚNotImplementedErrorr?  rA  Úarchiver  r©  r  r  r  rÅ   r  r  rO  r%  r'  rŸ   r5  rÊ   Úsplitextr=  r:  r<  r>  rY  r]  re  ri  rî  Újavaxrÿ  rk  râ  ÚPILrl  rn  r}  r„  r‡  rŽ  Úurllib2Úurllibr“  Ú	URLopenerr‰  r’  Úurllib.requestÚurllib.parser”  rš  r   r£  r¥  r§  rË   r«  rÌ   r®  ÚgetmtimeÚmktimer¹  r(  Ú	importlibr¼  r½  rÃ  rÄ  rË  rÍ  ÚobjectrÎ  rá  r  r  r‘  r’  r•  r–  r™  r¢  r¯  r¸  rº  r»  rÃ  rÄ  rÅ  rÉ  rM  rÍ  rÎ  rÔ  rÕ  ÚtzinforÖ  rå  r   r   r   r   Ú<module>   sà  (ÿÿ














	





	8ò
 


÷"
0ÿ€ý
,	




 
 '	 w

 

