§
    ¥”je:  ã                   ó†  — d Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddl	Z	ddl
Z
ddlZdxZZi 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d“dd“dddœ¥Zg d¢ZddlmZmZmZ ddlmZmZ d„ Z G d „ d!¦  «        Z G d"„ d#¦  «        Z G d$„ d%¦  «        Zdd&lmZ dd'lmZmZm Z m!Z! dd(l"m#Z#m$Z$ dS ))z~The Awesome Document Factory.

The public API is what is accessible from this "root" packages without
importing sub-modules.

é    )Údatetime)ÚgetctimeÚgetmtime)ÚPath)ÚurljoinNz68.1ÚstylesheetsÚattachmentsÚattachment_relationshipsÚpdf_identifierÚpdf_variantÚpdf_versionÚ	pdf_formsÚpdf_tagsFÚuncompressed_pdfÚxmp_metadataÚcustom_metadataÚpresentational_hintsÚsrgbÚoptimize_imagesÚjpeg_qualityÚdpiÚ
full_fonts)ÚhintingÚcache)	ÚCSSÚDEFAULT_OPTIONSÚHTMLÚVERSIONÚ
AttachmentÚDocumentÚPageÚ__version__Údefault_url_fetcheré   )Ú
URLFetcherr#   Úselect_source)ÚLOGGERÚPROGRESS_LOGGERc                 óÞ   — t          t          |                      d¦  «        ¦  «        d¦  «        }|�:|                     dd¦  «                             ¦   «         }|rt	          ||¦  «        S |S )zlReturn the base URL for the document.

    See https://www.w3.org/TR/html5/urls.html#document-base-url

    ÚbaseNÚhrefÚ )ÚnextÚiterÚgetÚstripr   )Úhtml_documentÚfallback_base_urlÚfirst_base_elementr+   s       úb/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/weasyprint/__init__.pyÚ_find_base_urlr5   e   sp   € õ �d =×#5Ò#5°fÑ#=Ô#=Ñ>Ô>ÀÑEÔEÐØÐ%Ø!×%Ò% f¨bÑ1Ô1×7Ò7Ñ9Ô9ˆØð 	4ÝÐ,¨dÑ3Ô3Ð3ØÐó    c                   óH   — e Zd ZdZ	 	 	 dd„Zdd„Zd„ Zd„ Zdd	„Z	 	 dd„Z	dS )r   a3  HTML document parsed by tinyhtml5.

    You can just create an instance with a positional argument:
    ``doc = HTML(something)``
    The class will try to guess if the input is a filename, an absolute URL,
    or a :term:`file object`.

    Alternatively, use **one** named argument so that no guessing is involved:

    :type filename: str or pathlib.Path
    :param filename:
        A filename, relative to the current directory, or absolute.
    :param str url:
        An absolute, fully qualified URL.
    :type file_obj: :term:`file object`
    :param file_obj:
        Any object with a ``read`` method.
    :param str string:
        A string of HTML source.

    Specifying multiple inputs is an error:
    ``HTML(filename="foo.html", url="localhost://bar.html")``
    will raise a :obj:`TypeError`.

    You can also pass optional named arguments:

    :param str encoding:
        Force the source character encoding.
    :type base_url: str or pathlib.Path
    :param base_url:
        The base used to resolve relative URLs (e.g. in
        ``<img src="../foo.png">``). If not provided, try to use the input
        filename, URL, or ``name`` attribute of
        :term:`file objects <file object>`.
    :type url_fetcher: :term:`callable`
    :param url_fetcher:
        An instance of :class:`urls.URLFetcher`. (See :ref:`URL Fetchers`.)
    :param str media_type:
        The media type to use for ``@media``. Defaults to ``'print'``.
        **Note:** In some cases like ``HTML(string=foo)`` relative URLs will be
        invalid if ``base_url`` is not provided.

    NÚprintc
           	      ó&  — t          j        d|p|p|pt          |dd¦  «        ¦  «         t          |t          ¦  «        rt          |¦  «        }|€t          ¦   «         }t          |||||||¦  «        }
|
5 \  }}}}ddi}|�||d<   |�||d<   t          j	        |fi |¤Ž}
d d d ¦  «         n# 1 swxY w Y   t          |
|¦  «        | _        || _        |	| _        t          j                             |
d ¬¦  «        | _        | j        j        | _        d S )	Nz'Step 1 - Fetching and parsing HTML - %sÚnamezHTML stringÚnamespace_html_elementsFÚtransport_encodingÚoverride_encoding)Úcontent_language)r(   ÚinfoÚgetattrÚ
isinstancer   Ústrr%   r&   Ú	tinyhtml5Úparser5   Úbase_urlÚurl_fetcherÚ
media_typeÚ
cssselect2ÚElementWrapperÚfrom_html_rootÚwrapper_elementÚetree_element)ÚselfÚguessÚfilenameÚurlÚfile_objÚstringÚencodingrE   rF   rG   ÚresultÚprotocol_encodingÚ_Úkwargss                 r4   Ú__init__zHTML.__init__Ÿ   s�  € õ 	ÔØ5Øð 5�Xð 5 ð 5Ý�H˜f mÑ4Ô4ñ	6ô 	6ð 	6õ �h¥Ñ%Ô%ð 	%Ý˜8‘}”}ˆHØÐÝ$™,œ,ˆKÝØ�8˜S (¨F°H¸kñKô Kˆàð 	9ÑA˜ (Ð,=¸qØ/°Ð7ˆFØ Ð,Ø/@�Ð+Ñ,ØÐ#Ø.6�Ð*Ñ+Ý”_ XÐ8Ð8°Ð8Ð8ˆFð	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9õ ' v¨xÑ8Ô8ˆŒØ&ˆÔØ$ˆŒÝ)Ô8×GÒGØ Tð  Hñ  +ô  +ˆÔà!Ô1Ô?ˆÔÐÐs   Á6*B,Â,B0Â3B0Fc                 ó2   — |rt           t          gS t           gS ©N)ÚHTML5_UA_STYLESHEETÚHTML5_UA_FORM_STYLESHEET)rM   Úformss     r4   Ú_ua_stylesheetszHTML._ua_stylesheetsº   s    € Øð 	CÝ'Õ)AÐBÐBÝ#Ð$Ð$r6   c                 ó*   — t          j        ¦   «         gS rZ   )ÚHTML5_UA_COUNTER_STYLEÚcopy©rM   s    r4   Ú_ua_counter_stylezHTML._ua_counter_style¿   s   € Ý&Ô+Ñ-Ô-Ð.Ð.r6   c                 ó   — t           gS rZ   )ÚHTML5_PH_STYLESHEETrb   s    r4   Ú_ph_stylesheetszHTML._ph_stylesheetsÂ   s   € Ý#Ð$Ð$r6   c                 ó
  — t          |¦  «        t          t          ¦  «        z
  D ]}t          j        d|¦  «         Œt                               ¦   «         }|                     |¦  «         |}t          j        | ||||¦  «        S )að  Lay out and paginate the document, but do not (yet) export it.

        This returns a :class:`document.Document` object which provides
        access to individual pages and various meta-data.
        See :meth:`write_pdf` to get a PDF directly.

        :type font_config: :class:`text.fonts.FontConfiguration`
        :param font_config:
            A font configuration handling ``@font-face`` rules.
        :type counter_style: :class:`css.counters.CounterStyle`
        :param counter_style:
            A dictionary storing ``@counter-style`` rules.
        :param options:
            The ``options`` parameter includes by default the
            :data:`DEFAULT_OPTIONS` values.
        :returns: A :class:`document.Document` object.

        zUnknown rendering option: %s.)Úsetr   r'   Úwarningra   Úupdater    Ú_render)rM   Úfont_configÚcounter_styleÚcolor_profilesÚoptionsÚunknownÚnew_optionss          r4   ÚrenderzHTML.renderÅ   s‹   € õ( ˜7‘|”|¥c­/Ñ&:Ô&:Ñ:ð 	Eð 	EˆGÝŒNÐ:¸GÑDÔDÐDÐDÝ%×*Ò*Ñ,Ô,ˆØ×Ò˜7Ñ#Ô#Ð#ØˆÝÔØ�+˜}¨n¸gñGô Gð 	Gr6   r$   c                 óž   — t                                ¦   «         }|                     |¦  «         |}  | j        |||fi |¤Žj        |||fi |¤ŽS )aE  Render the document to a PDF file.

        This is a shortcut for calling :meth:`render`, then
        :meth:`Document.write_pdf() <document.Document.write_pdf>`.

        :type target:
            :class:`str`, :class:`pathlib.Path` or :term:`file object`
        :param target:
            A filename where the PDF file is generated, a file object, or
            :obj:`None`.
        :param float zoom:
            The zoom factor in PDF units per CSS units.  **Warning**:
            All CSS units are affected, including physical units like
            ``cm`` and named sizes like ``A4``.  For values other than
            1, the physical CSS units will thus be "wrong".
        :type finisher: :term:`callable`
        :param finisher:
            A finisher function or callable that accepts the document and a
            :class:`pydyf.PDF` object as parameters. Can be passed to perform
            post-processing on the PDF right before the trailer is written.
        :type font_config: :class:`text.fonts.FontConfiguration`
        :param font_config:
            A font configuration handling ``@font-face`` rules.
        :type counter_style: :class:`css.counters.CounterStyle`
        :param counter_style:
            A dictionary storing ``@counter-style`` rules.
        :param options:
            The ``options`` parameter includes by default the
            :data:`DEFAULT_OPTIONS` values.
        :returns:
            The PDF as :obj:`bytes` if ``target`` is not provided or
            :obj:`None`, otherwise :obj:`None` (the PDF is written to
            ``target``).

        )r   ra   rj   rr   Ú	write_pdf)	rM   ÚtargetÚzoomÚfinisherrl   rm   rn   ro   rq   s	            r4   rt   zHTML.write_pdfá   ss   € õJ &×*Ò*Ñ,Ô,ˆØ×Ò˜7Ñ#Ô#Ð#ØˆðˆKˆDŒK˜ ]°NÐNÐNÀgÐNÐNÜ�v˜t Xð:ð :Ø18ð:ð :ð	;r6   )	NNNNNNNNr8   )F)NNN)Nr$   NNNN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__rX   r^   rc   rf   rr   rt   © r6   r4   r   r   s   sª   € € € € € ð*ð *ðV FJØ6:Ø.5ð@ð @ð @ð @ð6%ð %ð %ð %ð
/ð /ð /ð%ð %ð %ðGð Gð Gð Gð8 7;ØGKð*;ð *;ð *;ð *;ð *;ð *;r6   r   c                   ó$   — e Zd ZdZ	 	 	 	 	 dd„ZdS )r   a#  CSS stylesheet parsed by tinycss2.

    An instance is created in the same way as :class:`HTML`, with the same
    arguments.

    An additional argument called ``font_config`` must be provided to handle
    ``@font-face`` rules. The same ``text.fonts.FontConfiguration`` object
    must be used for different ``CSS`` objects applied to the same document.

    ``CSS`` objects have no public attributes or methods. They are only meant
    to be used in the :meth:`HTML.write_pdf` and :meth:`HTML.render` methods
    of :class:`HTML` objects.

    NFr8   c                 ój  — t          j        d|p|pt          |dd¦  «        ¦  «         |€t          ¦   «         }t	          ||||||||	¬¦  «        }|5 \  }}}}|                     ¦   «         }t          |t          ¦  «        rt          j	        |¦  «        }nt          j
        |||¬¦  «        \  }}d d d ¦  «         n# 1 swxY w Y   || _        |pt          j        ¦   «         | _        |€g n|| _        |€g n|| _        |€i n|}|€i n|}t#          |
|||| j        | j        | j        ||||¬¦  «         d S )Nz&Step 2 - Fetching and parsing CSS - %sr:   z
CSS string)rE   rF   Úcheck_css_mime_type)Úenvironment_encodingrU   )Úlayer)r(   r?   r@   r%   r&   ÚreadrA   rB   Útinycss2Úparse_stylesheetÚparse_stylesheet_bytesrE   rH   ÚMatcherÚmatcherÚ
page_rulesÚlayersÚpreprocess_stylesheet)rM   rN   rO   rP   rQ   rR   rS   rE   rF   Ú_check_mime_typerG   rl   rm   rn   r‡   rˆ   r‰   r�   rT   rU   Ú	mime_typeÚcssÚ
stylesheetrV   s                           r4   rX   zCSS.__init__  sÄ  € õ
 	ÔØ4ØÐF˜ÐF�w x°¸ÑFÔFñ	Hô 	Hð 	Hð ÐÝ$™,œ,ˆKÝØ�8˜S (¨F¸XØ#Ð9IðKñ Kô Kˆð ð 	9ÑI˜ (Ð,=¸yØ—-’-‘/”/ˆCÝ˜#�sÑ#Ô#ð 9Ý%Ô6°sÑ;Ô;�
�
å (Ô ?Ø¨hØ&7ð!9ñ !9ô !9‘�
˜Að	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9ð !ˆŒØÐ6¥*Ô"4Ñ"6Ô"6ˆŒØ *Ð 2˜"˜"¸
ˆŒØ"˜N�b�b°ˆŒØ+Ð3˜˜¸ˆØ-Ð5˜˜¸>ˆÝØ˜ *¨k¸4¼<ØŒO˜Tœ[¨+°}ÀnØð	ñ 	ô 	ð 	ð 	ð 	s   ÁAB<Â<C ÃC )NNNNNNNNFr8   NNNNNNN©rx   ry   rz   r{   rX   r|   r6   r4   r   r     sE   € € € € € ðð ð SWØRWØEIØLPØð	ð ð ð ð ð r6   r   c                   ó"   — e Zd ZdZ	 	 	 	 dd„ZdS )r   a¿  File attachment for a PDF document.

    An instance is created in the same way as :class:`HTML`, except that the
    HTML specific arguments (``encoding`` and ``media_type``) are not
    supported.

    :param str name:
        The name of the attachment to be included in the PDF document.
        May be :obj:`None`.
    :param str description:
        A description of the attachment to be included in the PDF document.
        May be :obj:`None`.
    :type created: :obj:`datetime.datetime`
    :param created:
        Creation date and time. Default is current date and time.
    :type modified: :obj:`datetime.datetime`
    :param modified:
        Modification date and time. Default is current date and time.
    :param str relationship:
        A string that represents the relationship between the attachment and
        the PDF it is embedded in. Default is 'Unspecified', other common
        values are defined in ISO-32000-2:2020, 7.11.3.

    NÚUnspecifiedc           	      ó”  — |€t          ¦   «         }t          |||||||¬¦  «        | _        || _        |	| _        || _        d | _        |
€7|r"t          j        t          |¦  «        ¦  «        }
nt          j
        ¦   «         }
|€7|r"t          j        t          |¦  «        ¦  «        }nt          j
        ¦   «         }|
| _        || _        d S )N)rE   rF   )r%   r&   Úsourcer:   ÚdescriptionÚrelationshipÚmd5r   Úfromtimestampr   Únowr   ÚcreatedÚmodified)rM   rN   rO   rP   rQ   rR   rE   rF   r:   r”   r™   rš   r•   s                r4   rX   zAttachment.__init__W  sÐ   € ð ÐÝ$™,œ,ˆKÝ#Ø�8˜S (¨F¸XØ#ð%ñ %ô %ˆŒð ˆŒ	Ø&ˆÔØ(ˆÔØˆŒàˆ?Øð )Ý"Ô0µ¸(Ñ1CÔ1CÑDÔD��å"œ,™.œ.�ØÐØð *Ý#Ô1µ(¸8Ñ2DÔ2DÑEÔE��å#œ<™>œ>�ØˆŒØ ˆŒˆˆr6   )NNNNNNNNNNNr‘   r�   r|   r6   r4   r   r   >  sB   € € € € € ðð ð0 FJØDHØ:>Ø+ð!ð !ð !ð !ð !ð !r6   r   )rŠ   )r`   r[   r\   re   )r    r!   )%r{   r   Úos.pathr   r   Úpathlibr   Úurllib.parser   rH   rƒ   rC   r   r"   r   Ú__all__Úurlsr%   r#   r&   Úloggerr'   r(   r5   r   r   r   r�   rŠ   Úhtmlr`   r[   r\   re   Údocumentr    r!   r|   r6   r4   ú<module>r£      s½  ððð ð Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ø €€€Ø Ð Ð Ð àÐ €ˆ+ðdØ�4ðà�4ðð  ðð �dð	ð
 �4ðð �4ðð �ðð �ðð ˜ðð �Dðð �uðð ˜Eðð ˆEðð �uðð �Dðð  
ˆ4ð!ð" �%ð#ð$ Øð'ð ð €ð,*ð *ð *€ð AÐ @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +ð
ð ð ðX;ð X;ð X;ð X;ð X;ñ X;ô X;ð X;ðv-ð -ð -ð -ð -ñ -ô -ð -ð`2!ð 2!ð 2!ð 2!ð 2!ñ 2!ô 2!ð 2!ðl 'Ð &Ð &Ð &Ð &Ð &ðð ð ð ð ð ð ð ð ð ð ð ð %Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ð $r6   