%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/reportlab/platypus/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/reportlab/platypus/__pycache__/tableofcontents.cpython-312.pyc

�

��dS���dZdZddlmZddlmZmZmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlmZdd	lmZmZdd
lmZddlmZddlmZdd
lZddl m!Z!d�Z"	e#d"d�Z%dezZ&dezZ'e
deddde'��gZ(egd��Z)Gd�de�Z*d�Z+Gd�de�Z,e,Z-d�Z.Gd �d!e�Z/y
#Gd�de$�Z#Y�`xYw)#z3.5.32aExperimental class to generate Tables of Contents easily

This module defines a single TableOfContents() class that can be used to
create automatically a table of tontents for Platypus documents like
this:

    story = []
    toc = TableOfContents()
    story.append(toc)
    # some heading paragraphs here...
    doc = MyTemplate(path)
    doc.multiBuild(story)

The data needed to create the table is a list of (level, text, pageNum)
triplets, plus some paragraph styles for each level of the table itself.
The triplets will usually be created in a document template's method
like afterFlowable(), making notification calls using the notify()
method with appropriate data like this:

    (level, text, pageNum) = ...
    self.notify('TOCEntry', (level, text, pageNum))

Optionally the list can contain four items in which case the last item
is a destination key which the entry should point to. A bookmark
with this key needs to be created first like this:

    key = 'ch%s' % self.seq.nextf('chapter')
    self.canv.bookmarkPage(key)
    self.notify('TOCEntry', (level, text, pageNum, key))

As the table of contents need at least two passes over the Platypus
story which is why the multiBuild() method must be called.

The level<NUMBER>ParaStyle variables are the paragraph styles used
to format the entries in the table of contents. Their indentation
is calculated like this: each entry starts at a multiple of some
constant named delta. If one entry spans more than one line, all
lines after the first are indented by the same constant named
epsilon.
�)�cm)�
commasplit�
escapeOnce�encode_label�decode_label�strTypes�	asUnicode�asNative)�ParagraphStyle�
_baseFontName)�	sequencer)�	Paragraph)�IndexingFlowable)�
TableStyle�Table)�Spacer)�stringWidth��canvasN)�literal_evalc�&�ddlm}||ddd��S)Nr)�unescape�'�")z&apos;z&quot;)�xml.sax.saxutilsr)�txtrs  �D/usr/lib/python3/dist-packages/reportlab/platypus/tableofcontents.py�unquoter<s��)��C�C�3�7�8�8�c��eZdZd�Zy)�setc�:�||vrtj||�yy�N)�list�append)�self�xs  r�addzset.addDs����}����D��#�rN)�__name__�
__module__�__qualname__r(�rrr!r!Cs��	$rr!c
��dj|D��cgc]\}}t|���c}}�}	|jd|jd}}
|j}t	|	|j
|�}
||
z
}|
|kDr,|dk\r'd|z}t	|	|j
|�}
|
|kDr|dk\r�'t
|t�rL|r,t	||j
|�}t||
z
|
z
|z�}ndx}}||z�|	��}|||zz
|
z
}||
z
}n|�
d|	z}|
}|}ntd	��|j||�}|j|j
|�|j|j�|j|�|j|�t	d|j
|�}|D]Z\}}|s�	t	t|�|j
|�}|j d
|||||z||j"zfd��|||zz
}�\ycc}}w)
z�
    Draws pagestr on the canvas using the given style.
    If dot is None, pagestr is drawn at the current position in the canvas.
    If dot is a string, pagestr is drawn right-aligned. If the string is not empty,
    the gap is filled with it.
    �, �cur_x�cur_yg�?g�������?rNz,  z@Argument dot should either be None or an instance of basestring.��)�relative)�join�str�
_curr_tx_info�fontSizer�fontName�
isinstancer�int�	TypeError�	beginText�setFont�setFillColor�	textColor�textLine�drawText�linkRect�leading)r�style�pages�
availWidth�availHeight�dot�	formatter�p�_�pagestrr'�yr7�pagestrw�	freeWidth�dotw�dotsn�text�newx�pagex�tx�commaw�key�ws                        r�drawPageNumbersrYHs���i�i�E�2�D�A�q��Q��2�3�G�����(�&�*>�*>�w�*G�q�A��~�~�H��7�E�N�N�H�=�H��1��I�
�Y�
�8�s�?���>���w�����A���Y�
�8�s�?�
�#�x� ���s�E�N�N�H�=�D���A��h�.��4�5�E���E�D����g�.���E�$�J�&��1���X�%��	���w��������Z�[�[�	��	�	�$��	"�B��J�J�u�~�~�x�(��O�O�E�O�O�$��K�K����F�O�O�B��
��u�~�~�x�
8�F�����3�����A������9�������C�%��E�!�G�Q�u�}�}�_�!E�PQ�R�
��V������Q3s�G<
r2g�?zLevel 0�
�)�namer8r7rC�firstLineIndent�
leftIndent))�VALIGN�rr����rb�TOP)�RIGHTPADDINGr`rar)�LEFTPADDINGr`rarc�\�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd
�Zd�Zd�Z
d
�Zdd�Zy	)�TableOfContentsa�This creates a formatted table of contents.

    It presumes a correct block of data is passed in.
    The data block contains a list of (level, text, pageNumber)
    triplets.  You can supply a paragraph style for each level
    (starting at zero).
    Set dotsMinLevel to determine from which level on a line of
    dots should be drawn between the text and the page number.
    If dotsMinLevel is set to a negative value, no dotted lines are drawn.
    c�~�|jdd�|_|jdt�|_|jdt�|_|jdd�|_|jdd�|_|r+tdd	j|j��z��d|_g|_g|_
y)
N�rightColumnWidth�H�levelStyles�
tableStyle�dotsMinLevelr2rIzunexpected keyword arguments %sr.)�popri�defaultLevelStylesrk�defaultTableStylerlrmrI�
ValueErrorr4�keys�_table�_entries�_lastEntries)r&�kwdss  r�__init__zTableOfContents.__init__�s��� $���);�B� ?����8�8�M�2D�E����(�(�<�0A�B��� �H�H�^�A�6������+�d�3����z�"C�d�i�i�PT�PY�PY�P[�F\�"\�]�]������
���rc�L�|jdd|_|j�yr#)rtru�clearEntries�r&s r�beforeBuildzTableOfContents.beforeBuild�s�� �M�M�!�,������rc��y�Nr2r,rzs r�
isIndexingzTableOfContents.isIndexing����rc�4�|j|jk(Sr#�rtrurzs r�isSatisfiedzTableOfContents.isSatisfied�����
�
��!2�!2�2�3rc�.�|dk(r|j|�yy)z�The notification hook called to register all kinds of events.

        Here we are interested in 'TOCEntry' events only.
        �TOCEntryN��addEntry)r&�kind�stuffs   r�notifyzTableOfContents.notify�s��
�:���D�M�M�5�!�rc��g|_yr#�rtrzs rryzTableOfContents.clearEntries��	����
rc
�8�	|j|S#t$r|j|dz
�}|jjt	d|j
|fz||jtz|jtz���|j|cYSwxYw)�VReturns the style for level n, generating and caching styles on demand if not present.r2�%s-%d-indented�r\�parentr]r^)	rk�
IndexError�
getLevelStyler%rr\r]�deltar^�r&�n�	prevstyles   rr�zTableOfContents.getLevelStyle�s���		'��#�#�A�&�&���	'��*�*�1�Q�3�/�I����#�#�N�)�Y�^�^�Q�,?�?�$�&/�&?�&?��&E�!*�!5�!5�e�!;�	%=�
>�
�#�#�A�&�&�	'�s��BB�BNc�~�t|�td�k(sJd��|jj||||f�y)z�Adds one entry to the table of contents.

        This allows incremental buildup by a doctemplate.
        Requires that enough styles are defined.r2zLevel must be an integerN)�typertr%)r&�levelrR�pageNumrWs     rr�zTableOfContents.addEntry�s;���E�{�d�1�g�%�A�'A�A�%��
�
���e�T�7�C�8�9rc�0�|D]}|j|��y)z�Bulk creation of entries in the table of contents.

        If you knew the titles but not the page numbers, you could
        supply them to get sensible output on the first run.Nr�)r&�
listOfEntries�	entryargss   r�
addEntrieszTableOfContents.addEntries�s!��'�	&�I��D�M�M�9�%�	&rc�����t�j�dk(rdg}n�j}���fd�}|�j_g}|D]�\}}}}	�j	|�}
|	r5d|	�d|�d�}t|	�j
dd�j
d	d�}nd
}td||||fz|
�}|
jr&|jtd|
j�g�|j|g���t|�f�j�
��_
�jj�j���\�_�_�j�j fS)�,All table properties should be known by now.r)rz!Placeholder for table of contentsrNc�D��|jd�}t|d�t|d�t|d�}}}�
j|�}�
jdk\r|�
jk\rd}nd}�
j
r�
j|�}t
||||fg�	�|�y)�8Callback to draw dots and page numbers after each entry.�,rr2�� . r1N)�splitr:rr�rmrIrY)rr��label�pager�rWrDrHrGrFr&s        ���r�drawTOCEntryEndz-TableOfContents.wrap.<locals>.drawTOCEntryEnd�s�����K�K��$�E�"�5��8�}�c�%��(�m�\�%�PQ�(�=S��%�D��&�&�u�-�E�� � �A�%�%�4�3D�3D�*D������~�~�d�n�n�T�&:�t��F�E�T�3�K�=�*�k�SV�Wrz
<a href="#z">z</a>r�z\x2crNz3%s<onDraw name="drawTOCEntryEnd" label="%d,%d,%s"/>r2��	colWidthsrD)�lenru�canvr�r��repr�replacer�spaceBeforer%rrrlrs�wrapOn�width�height)
r&rFrG�_tempEntriesr��	tableDatar�rRr�rWrD�keyVal�paras
```          r�wrapzTableOfContents.wrap�sH����t� � �!�Q�&�J�K�L��,�,�L�
	X�%4��	�	�!��	�+7�
	&�'�U�D�'�3��&�&�u�-�E��14�d�;���c��*�*�3�w�7�?�?��G�L�����R�VZ�\c�ej�lr�Us�s�uz�{�D�� � �� � �&��E�,=�,=�">�!@�A����d�W�%�
	&��I�*��d�o�o�V���"&�+�+�"4�"4�T�Y�Y�z�;�"W���
�D�K��
�
�D�K�K�(�(rc�P�|jj|j||�S�z�At this stage we do not care about splitting the entries,
        we will just return a list of platypus tables.  Presumably the
        calling app has a pointer to the original TableOfContents object;
        Platypus just sees tables.
        )rs�splitOnr��r&rFrGs   rr�zTableOfContents.splits!���{�{�"�"�4�9�9�Z��E�Erc�@�|jj||||�y�z�Don't do this at home!  The standard calls for implementing
        draw(); we are hooking this in order to delegate ALL the drawing
        work to the embedded table object.
        N)rs�drawOn�r&rr'rM�_sWs     rr�zTableOfContents.drawOns��
	
�����6�1�a��-rr#�r)r)r*r+�__doc__rwr{r~r�r�ryr�r�r�r�r�r�r,rrrgrg�sE��	�	��
�4�"��'�:�&�))�XF�.rrgc�J�t|ttf�rt|�S|fSr#)r9r$�tuple)r's r�	makeTupler� s ���!�T�%�L�!��Q�x��
�4�Krc��eZdZdZd�Zd�Zdd�Zd�Zejfd�Z
d�Zd	�Zd
�Z
d�Zd�Zdd
�Zd�Zdged�fgfd�Zd�Zd�Zdd�Zd�Zd�Zy)�SimpleIndexzlCreates multi level indexes.
    The styling can be cutomized and alphabetic headers turned on and off.
    c�R�i|_i|_d|_|jdi|��y)ze
        Constructor of SimpleIndex.
        Accepts the same arguments as the setup method.
        Nr,)rtru�	_flowable�setup)r&�kwargss  rrwzSimpleIndex.__init__*s+����
���������
�
��V�rc�`�	ttd|z�S#t$rtd|z��wxYw)Nz
_format_%szUnknown sequencer format %r)�getattr�rl_sequencer�ImportErrorrq)r&�
formatNames  r�
getFormatFunczSimpleIndex.getFormatFunc5s<��	I��<��z�(A�B�B���	I��:�Z�G�H�H�	I�s��-Nc���|�tdtd��}||_|xst|_||_||_|�ddlm}||_	|j|�|_||_y)a�
        This method makes it possible to change styling and other parameters on an existing object.

        style is the paragraph style to use for index entries.
        dot can either be None or a string. If it's None, entries are immediatly followed by their
            corresponding page numbers. If it's a string, page numbers are aligned on the right side
            of the document and the gap filled with a repeating sequence of the string.
        tableStyle is the style used by the table which the index uses to draw itself. Use this to
            change properties like spacing between elements.
        headers is a boolean. If it is True, alphabetic headers are displayed in the Index when the first
        letter changes. If False, we just output some extra space before the next item
        name makes it possible to use several indexes in one document. If you want this use this
            parameter to give each index a unique name. You can then index a term by refering to the
            name of the index which it should appear in:

                <index item="term" name="myindex" />

        format can be 'I', 'i', '123',  'ABC', 'abc'
        N�indexr[)r\r8r7r)�DEFAULT_INDEX_NAME)
rr�	textStylerprlrH�headers�reportlab.platypus.paraparserr�r\r��
formatFunc�offset)r&rDrHrlr�r\�formatr�s        rr�zSimpleIndex.setup;sg��*�=�"��1>�13�5�E����$�9�(9����������<�P���	��,�,�V�4�����rc��t|d�}	t|�\}}}|�
|j}n|j|�}|�|j}t|�}|j
�}|||z
�}	d|j�d|�d|	��}
|j}|j|
|d|d|dz�|j|||	f|
�y#|}dx}}Y��xYw)N�latin1�ix_rK�_p_r/r0rC)r
rr�r�r�r�
getPageNumberr\r6�bookmarkHorizontalr�)r&r�r�r��termsr�r�r��cPN�pnsrW�infos            r�__call__zSimpleIndex.__call__^s�����x�(��	#�$0��$7�!�E�6�6��>����J��+�+�F�3�J��>��[�[�F��5�!��� � �"����V��$��!%���E�3�7���!�!������T�'�]�D��M�D��O�4S�T��
�
�e�c�#�Y��,��#	#��E�"�"�F�V�s�C�Cc������fd�}|S)Nc�R��ddlm}�|i|��}t|�j��|S)Nrr)�reportlab.pdfgenr�setattrr\)�argsr�r�c�canvasmakerr&s    ��r�newcanvasmakerz2SimpleIndex.getCanvasMaker.<locals>.newcanvasmakerws*���/��T�,�V�,�A��A�d�i�i��%��Hrr,)r&r�r�s`` r�getCanvasMakerzSimpleIndex.getCanvasMakerus���	��rc��yr}r,rzs rr~zSimpleIndex.isIndexingrrc�4�|j|jk(Sr#r�rzs rr�zSimpleIndex.isSatisfied�r�rc�b�|jj�|_|j�yr#)rt�copyruryrzs rr{zSimpleIndex.beforeBuild�s#�� �M�M�.�.�0������rc��i|_yr#r�rzs rryzSimpleIndex.clearEntries�r�rc�r�|dk(r2|\}}|j||jj�|f�yy)z�The notification hook called to register all kinds of events.

        Here we are interested in 'IndexEntry' events only.
        �
IndexEntryN)r��_canvr�)r&r�r�rRr�s     rr�zSimpleIndex.notify�s:��
�<��!�M�D�'��M�M�$����!9�!9�!;�G� D�E� rc��|jjt|�tg��j	||f�y)zAllows incremental buildupN)rt�
setdefaultr�r!r()r&rRr�rWs    rr�zSimpleIndex.addEntry�s-���
�
� � ��4���R��9�=�=�w��n�Mrc�P�|jj|j||�Sr�)r�r�r�r�s   rr�zSimpleIndex.split�s!���~�~�%�%�d�i�i�
�K�H�HrzPlaceholder for index)NNNc��|jxs|j}|s|Stt|j	���S)zAReturn the last run's entries!  If there are none, returns dummy.)rurtr$�sorted�items)r&�dummy�lEs   r�_getlastEntrieszSimpleIndex._getlastEntries�s4��
�
�
�
/�$�-�-����L��F�2�8�8�:�&�'�'rc	�������j�D��cgc]\}}td�|D��|f��}}}d�}|j|���jxrdxsd�����fd�}|�j_d}g}	g}
�j
d�}|D�]�\}}t|�}djd�tjd	|ddj��D��}||k7r{|}�jr|}
nd
}
|	jtd|j�g�|	jt|
|�g�|	jtd|j �g�t#|
|�\}}|r|}
||d}t%t|��}|d�d|�d
�|d<|D]v}t'|�}�j
|�z�}t||�}|jr&|	jtd|j�g�|	j|g�|dz
}�x���t)|	�g�j*���_ycc}}w)Nc3�2K�|]}t|����y�wr#)r	)�.0�ts  r�	<genexpr>z%SimpleIndex._build.<locals>.<genexpr>�s����;��y��|�;�s�c��|dD�cgc]<}djd�tjd|j��D����>c}Scc}w)Nrr1c3�RK�|]}tj|�dk7s�|���!y�w��MnN��unicodedata�category�rr�s  rrz5SimpleIndex._build.<locals>.getkey.<locals>.<genexpr>�s%����s�1�S^�Sg�Sg�hi�Sj�nr�Sr�Q�s���'�'�NFD)r4r
�	normalize�upper)�seqr's  r�getkeyz"SimpleIndex._build.<locals>.getkey�sW��B�CD�E�F�yz�B�G�G�s��(=�(=�e�Q�W�W�Y�(O�s�t�F�
F��Fs�AA)rWr2rc����
j�	�}tt|��D��cgc]\}}|d|f��}}}t|||���
j�ycc}}w)r�r2N)r�r�rrYrH)rr�r�rDrJ�krErGrF�leveloffsetr&s       ����r�drawIndexEntryEndz-SimpleIndex._build.<locals>.drawIndexEntryEnd�sX����&�&�{�3�E�)/��U�0C�)D�E�#�!�A�a��d�1�X�E�E�E��F�E�5�*�k�4�8�8�T��Fs�Ar1c3�RK�|]}tj|�dk7s�|���!y�wr
rrs  rrz%SimpleIndex._build.<locals>.<genexpr>�s%����~�A�^i�^r�^r�st�^u�y}�^}�a�~�rr� rbz(<onDraw name="drawIndexEntryEnd" label="z"/>r�)rr��sortr�r�rr�r$r4r
rrr%rr�r�
spaceAfter�listdiffrrrrlr�)r&rFrG�texts�pageNumbersr�rr�alphar��	lastTexts�
alphaStyle�nalpha�header�i�diffr�rRrDr�rs```                 @r�_buildzSimpleIndex._build�sB���6:�6J�6J�6L�N� 2��{��;�U�;�;�K�H�N��N�	F����f��%��l�l�(�q�-�A��	U�
'8��	�	�#����	��	��'�'��*�
�".�"	��E�;���K�E��W�W�~��)>�)>�u�e�A�h�q�k�FW�FW�FY�)Z�~��F�������<�<�"�F� �F�� � �&��J�,B�,B�"C�!E�F�� � �)�F�J�"?�!A�B�� � �&��J�,A�,A�"B�!D�E��y�%�0�G�A�t��!�	��a�b�	�� ��k�!2�3�E�MR�SU�Y�X]�^�E�"�I��
��"�$�'���*�*�1�[�=�9�� ��u�-���$�$��$�$�f�Q��0A�0A�&B�%D�E�� � �$��)��Q���
�/"	�H�y�Z�L����X����mNs�H=c��|j||�|jj|j||�\|_|_|j|j
fS)r�)r(r�r�r�r�r�r�s   rr�zSimpleIndex.wrap�sH�����J�{�+�"&�.�.�"7�"7��	�	�*�k�"Z���
�D�K��z�z�4�;�;�&�&rc�@�|jj||||�yr�)r�r�r�s     rr�zSimpleIndex.drawOn�s��
	
�����f�a��C�0rc��|j}t|dd�}|s|j|_	|j�|s|`yy#|s|`wwxYw)Nr�)r�r�r��draw)r&r�ocanvs   rr,zSimpleIndex.draw�sP���N�N����&��&����Y�Y�A�F�	�
�F�F�H���F���5��F��s�A�Ac���t|jd�s|jg|_	|j|S#t$r�t|j�|_|j	|dz
�}|jjt
d|j|fz||jdtzz|jdtzz���|j|cYSwxYw)r��__iter__r2r�g�������?r�)�hasattrr�r�r$r�r%rr\r]rr^r�s   rr�zSimpleIndex.getLevelStyle�s����t�~�~�z�2�"�n�n�-�D�N�
	%��>�>�!�$�$���	%�!�$�.�.�1�D�N��*�*�1�Q�3�/�I��N�N�!�!�.�)�Y�^�^�Q�,?�?�$�&/�&?�&?��2��&E�!*�!5�!5�b��e�!;�	#=�
>�
�>�>�!�$�$�	%�s�9�B%C!� C!)NNNTN�123rr#r�)r)r*r+r�rwr�r�r�r�Canvasr�r~r�r{ryr�r�r��	enumeraterr(r�r�r,r�r,rrr�r�%s����	�I�!�F-�.*0�����4��
�F�N�I�(?�&?�	�)�@T�%U�$V�(�7Y�r'�1�	�%rr�c��tt|�t|��}t|�D]}||||k7s�|||dfcS|||dfSr#)�minr��range)�l1�l2�mr&s    rrrsZ���C��G�S��W��A�
�1�X���
�a�5�B�q�E�>��b���f�9���
�b���f�9�rc�0�eZdZdZd�Zd�Zd�Zd�Zdd�Zy)	�
ReferenceTextzVFakery to illustrate how a reference would work if we could
    put it in a paragraph.c�j�||_||_td�|_d|_d|_d|_y)N�tmpi���)�textPattern�targetr�	paraStyle�_lastPageNum�_pageNum�_para)r&r>�	targetKeys   rrwzReferenceText.__init__s3��&������'��.��� �����
���
rc�&�|j|_yr#)rBrArzs rr{zReferenceText.beforeBuilds�� �M�M��rc�H�|dk(r|\}}||jk(r||_yyy)N�Target)r?rB)r&r�r�rWr�s     rr�zReferenceText.notify!s0���8��"�N�S�'��d�k�k�!� '��
�"�rc��|j|jz}t||j�|_|jj||�Sr#)r>rArr@rCr�)r&rFrGrRs    rr�zReferenceText.wrap's?�����$�"3�"3�3���t�T�^�^�4��
��z�z���z�;�7�7rc�@�|jj||||�yr#)rCr�r�s     rr�zReferenceText.drawOn,s���
�
���&�!�Q��,rNr�)	r)r*r+r�rwr{r�r�r�r,rrr;r;s ����*�(�8�
-rr;)r�N)0�__version__r��reportlab.lib.unitsr�reportlab.lib.utilsrrrrrr	r
�reportlab.lib.stylesrr�
reportlab.libr
r��reportlab.platypus.paragraphr�reportlab.platypus.doctemplater�reportlab.platypus.tablesrr�reportlab.platypus.flowablesr�reportlab.pdfbase.pdfmetricsrr�rr
�astrrr!r$rYr��epsilonrorprgr�r��AlphabeticIndexrr;r,rr�<module>rWs���

��'	��R#�q�q�q�>�3�2�;�7�/�4�#���9�$��4�v	
�"���

�b�&���
������
�������H.�&�H.�T�
c%�"�c%�J���-�$�-��c$�$�d�$�s�B2�2
C

Zerion Mini Shell 1.0