a
    QhNC                     @   s  d Z dZdZddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZmZmZmZmZ m!Z"m#Z$m%Z& eeddZ'eeddZ(eeddZ)G d	d
 d
Z*G dd de*Z+e,eeeee	dfddZ-G dd de*Z.G dd de*Z/e0 Z1G dd dZ2dd Z3dd Z4dS )z3.3.0a  Classes for ParagraphStyle and similar things.

A style is a collection of attributes, but with some extra features
to allow 'inheritance' from a parent, and to ensure nobody makes
changes after construction.

ParagraphStyle shows all the attributes available for formatting
paragraphs.

getSampleStyleSheet()  returns a stylesheet you can use for initial
development, with a few basic heading and text styles.
)PropertySetParagraphStyleZstr2alignmentLineStyle	ListStyleStyleSheet1getSampleStyleSheet    )black)TA_LEFT	TA_CENTERTA_RIGHT
TA_JUSTIFY)tt2ps)canvas_basefontnameunderlineWidthunderlineOffsetunderlineGapstrikeWidthstrikeOffset	strikeGapspaceShrinkageplatypus_link_underlinehyphenationLanghyphenationMinWordLengthuriWasteReduceembeddedHyphenation   c                   @   sF   e Zd Zi ZdddZdd Zdd Zdd	 ZdddZdddZ	dS )r   Nc                 K   s   d| j vsJ dd| j vs$J d|rL|j| jksLJ d|jj| jjf || _|| _| j| j  |   | jf i | dS )zWhen initialized, it copies the class defaults;
        then takes a copy of the attributes of the parent
        if any.  All the work is done in init - styles
        should cost little to use at runtime.namez1Class Defaults may not contain a 'name' attributeparentz3Class Defaults may not contain a 'parent' attributez4Parent style %s must have same class as new style %sN)	defaults	__class____name__r   r   __dict__updaterefresh_setKwds)selfr   r   kw r&   M/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/lib/styles.py__init__6   s    $zPropertySet.__init__c                 K   s    |  D ]\}}|| j|< qd S N)itemsr    )r$   r%   keyvaluer&   r&   r'   r#   L   s    zPropertySet._setKwdsc                 C   s   d| j j| jf S )Nz	<%s '%s'>)r   r   r   r$   r&   r&   r'   __repr__Q   s    zPropertySet.__repr__c                 C   s2   | j r.| j j D ]\}}|dvr|| j|< qdS )zre-fetches attributes from the parent on demand;
        use if you have been hacking the styles.  This is
        used by __init__)r   r   N)r   r    r*   )r$   r+   r,   r&   r&   r'   r"   T   s    zPropertySet.refresh c                 C   sz   t |d | j t |d | j t| j }|  |d |d |D ]&}| j|d }t |d||f   qNd S )Nzname =zparent =r   r   z%s = %s)	printr   r   listr    keyssortremoveget)r$   indentZkeylistr+   r,   r&   r&   r'   	listAttrs]   s    

zPropertySet.listAttrsc                 K   sD   |  ||}| j |_||_|d u r*| p,||_|jf i | |S r)   )r   r    copyr   r   r#   )r$   r   r   kwdsrr&   r&   r'   cloneh   s    zPropertySet.clone)N)r/   )N)
r   
__module____qualname__r   r(   r#   r.   r"   r7   r;   r&   r&   r&   r'   r   3   s   
	
r   c                )   @   sb   e Zd Zedddddeddeddedddddddddddedddeee	e
eeeddeeed(ZdS )r   
      r   Nr   start)(fontNamefontSizeleading
leftIndentrightIndentfirstLineIndent	alignmentspaceBefore
spaceAfterbulletFontNamebulletFontSizebulletIndent	textColor	backColorZwordWrapZborderWidthZborderPaddingZborderColorZborderRadiusZallowWidowsZallowOrphansZtextTransformZendDotsZsplitLongWordsr   ZbulletAnchorZjustifyLastLineZjustifyBreaksr   r   r   r   r   r   ZlinkUnderlineZunderlineColorZstrikeColorr   r   r   )r   r<   r=   _baseFontNamer   r   _baseUnderlineWidth_spaceShrinkage_baseStrikeWidth_baseUnderlineOffset_baseUnderlineGap_baseStrikeOffset_baseStrikeGap_platypus_link_underline_hyphenationLang_embeddedHyphenation_uriWasteReducer   r&   r&   r&   r'   r   p   sR   r   )centrecenterleftrightZjustifyc                 C   s.   | |  d }|d ur|S t| dd S )Nz is illegal value for alignment)r5   lower
ValueError)vZ__map___r&   r&   r'   str2alignment   s    rc   c                   @   s   e Zd ZdedZdd ZdS )	LineStyler   )widthcolorc                 C   s   | d dS )zKYou can ask a LineStyle to set up the canvas for drawing
        the lines.r   N)setLineWidth)r$   canvasr&   r&   r'   prepareCanvas   s    zLineStyle.prepareCanvasN)r   r<   r=   r   r   ri   r&   r&   r&   r'   rd      s   rd   c                   @   s,   e Zd Zeddddedddddd	d	d
Zd	S )r      r   r]   1	Helveticar?   autoltrN)rD   rE   bulletAlign
bulletTypebulletColorrJ   rK   bulletOffsetYbulletDedent	bulletDirbulletFormatr@   )r   r<   r=   dictr   r   r&   r&   r&   r'   r      s   r   c                   @   sN   e Zd ZdZdd Zdd ZefddZdd	 Zd
d Z	dddZ
dd ZdS )r   aG  
    This may or may not be used.  The idea is to:
    
    1. slightly simplify construction of stylesheets;
    
    2. enforce rules to validate styles when added
       (e.g. we may choose to disallow having both
       'heading1' and 'Heading1' - actual rules are
       open to discussion);
       
    3. allow aliases and alternate style lookup
       mechanisms
       
    4. Have a place to hang style-manipulation
       methods (save, load, maybe support a GUI
       editor)
   
    Access is via getitem, so they can be
    compatible with plain old dictionaries.
    c                 C   s   i | _ i | _d S r)   )byNamebyAliasr-   r&   r&   r'   r(      s    zStyleSheet1.__init__c                 C   sT   z| j | W S  tyN   z| j| W  Y S  tyH   td| Y n0 Y n0 d S )Nz"Style '%s' not found in stylesheet)rx   KeyErrorrw   r$   r+   r&   r&   r'   __getitem__   s    zStyleSheet1.__getitem__c                 C   s4   z
| | W S  t y.   |tkr(| Y S  Y n0 d S r)   )ry   _stylesheet1_undefined)r$   r+   defaultr&   r&   r'   r5      s
    
zStyleSheet1.getc                 C   s   || j v p|| jv S r)   )rx   rw   rz   r&   r&   r'   __contains__   s    zStyleSheet1.__contains__c                 C   s   || v S r)   r&   rz   r&   r&   r'   has_key   s    zStyleSheet1.has_keyNc                 C   s~   |j }|| jv rtd| || jv r2td| |rb|| jv rLtd| || jv rbtd| || j|< |rz|| j|< d S )Nz(Style '%s' already defined in stylesheetz1Style name '%s' is already an alias in stylesheetz1Alias name '%s' is already an alias in stylesheet)r   rw   ry   rx   )r$   stylealiasr+   r&   r&   r'   add   s    




zStyleSheet1.addc                 C   sr   t | j }|  i }t | j D ]\}}|||< q(|D ].\}}||d }t|| |d t  q>d S )Nz    )r1   rw   r*   r3   rx   r5   r0   r7   )r$   stylesZaliir   r   r   r&   r&   r'   r1     s    


zStyleSheet1.list)N)r   r<   r=   __doc__r(   r{   r|   r5   r~   r   r   r1   r&   r&   r&   r'   r      s   	
r   c                  C   sJ   t dd } t| _d| _d| _|   t  t d| }d|_|  | |fS )NNormalr?   g,@LiteralCourier)r   rO   rA   rB   rC   r7   r0   )ZpNormalZpPrer&   r&   r'   
testStyles  s    

r   c                  C   s
  t  } | tdtddd | td| d dd | td| d td	 | jtd
| d tdddddd | jtd| d tddtdddd | jtd| d tddddddd | jtd| d tddddddd | jtd| d tddddddd | jtd| d tdddddd d | jtd!| d td"d#dd$dd%d | jtd&| d d'd(d)d*d | jtd+| d d'd,d'dtd-d.d | td/| d d0dd1d'd,d2d3 | jtd4d5dd'd6d7t	d8dd'd9d:d5d5d;d<d | jtd=d5dd'd6d7t	d8dd'd9d:d5d5d;d>d | S )?zReturns a stylesheet objectr   r>   r?   )r   rA   rB   rC   ZBodyText   )r   r   rH   Italic)r   r   rA   ZHeading1rj      )r   r   rA   rB   rC   rI   h1)r   ZTitle)r   r   rA   rB   rC   rG   rI   titleZHeading2   )r   r   rA   rB   rC   rH   rI   Zh2ZHeading3Zh3ZHeading4   Zh4ZHeading5	   g%@   Zh5ZHeading6   g @   Zh6ZBulletr      )r   r   rF   rH   ZbuZ
Definition$   )r   r   rF   rD   rL   rH   rJ   dfCoder   g!@r/   )r   r   rA   rB   rC   rF   rD   r   ZUnorderedListNr]   rk   rl   rm   rn   )r   r   rD   rE   ro   rp   rq   rJ   rK   rr   rs   rt   ru   r@   ulZOrderedListZol)
r   r   r   rO   _baseFontNameI_baseFontNameBr	   _baseFontNameBIr   r   )Z
stylesheetr&   r&   r'   r   %  s    								r   N)5__version__r   __all__reportlab.lib.colorsr   reportlab.lib.enumsr   r	   r
   r   Zreportlab.lib.fontsr   reportlab.rl_configr   rO   r   rP   r   rS   r   rT   r   rR   r   rU   r   rV   r   rQ   r   rW   r   rX   r   Z_hyphenationMinWordLengthr   rZ   r   rY   r   r   r   r   r   rv   rc   rd   r   objectr|   r   r   r   r&   r&   r&   r'   <module>   s.   	<=3M