Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 0øªjò6ã @súdZddlZddlmZddlZddlZddlZdZZddddd d d d gZ d dl m Z m Z m Z mZmZd dlmZmZGdd„dƒZGdd„dƒZGdd„dƒZejdddddde dfdd„ƒZd dlmZd dlmZmZmZmZd dlm Z m!Z!dS)z¶ WeasyPrint ========== WeasyPrint converts web documents to PDF. The public API is what is accessible from this "root" packages without importing sub-modules. éN)ÚPathz54.3ÚHTMLÚCSSÚ AttachmentÚDocumentÚPageÚdefault_url_fetcherÚVERSIONÚ __version__é)ÚfetchrÚpath2urlÚ ensure_urlÚurl_is_absolute)ÚLOGGERÚPROGRESS_LOGGERc @sXeZdZdZdddddddedf dd„Zdd„Zdd „Zd d „Zddd„Z ddd„Z dS)radHTML document parsed by html5lib. 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. :param str base_url: The base used to resolve relative URLs (e.g. in ````). If not provided, try to use the input filename, URL, or ``name`` attribute of :term:`file objects `. :type url_fetcher: :term:`function` :param url_fetcher: A function or other callable with the same signature as :func:`default_url_fetcher` called to fetch external resources such as stylesheets and images. (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  Cs°tjd|p|p|pt|ddƒƒt|||||||ƒ} | �:\} } }} t| tƒr\tj| dd�} ntj| || dd�} WdQRXt| |ƒ|_ ||_ | |_ t j j| dd�|_|jj|_dS)Nz'Step 1 - Fetching and parsing HTML - %sÚnamez HTML stringF)ÚnamespaceHTMLElements)Úoverride_encodingÚtransport_encodingr)Zcontent_language)rÚinfoÚgetattrÚ_select_sourceÚ isinstanceÚstrÚhtml5libÚparseÚ find_base_urlÚbase_urlÚ url_fetcherÚ media_typeÚ cssselect2ZElementWrapperZfrom_html_rootZwrapper_elementZ etree_element)ÚselfÚguessÚfilenameÚurlÚfile_objÚstringÚencodingrr r!ÚresultÚ source_typeÚsourceÚprotocol_encoding©r.ú9/tmp/pip-build-_d5lkt3n/weasyprint/weasyprint/__init__.pyÚ__init__Js&    z HTML.__init__cCstgS)N)ÚHTML5_UA_STYLESHEET)r#r.r.r/Ú_ua_stylesheetsbszHTML._ua_stylesheetscCs tjƒgS)N)ÚHTML5_UA_COUNTER_STYLEÚcopy)r#r.r.r/Ú_ua_counter_styleeszHTML._ua_counter_stylecCstgS)N)ÚHTML5_PH_STYLESHEET)r#r.r.r/Ú_ph_stylesheetshszHTML._ph_stylesheetsFÚfontscCstj|||||||ƒS)ahLay 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. .. versionadded:: 0.15 :param list stylesheets: An optional list of user stylesheets. List elements are :class:`CSS` objects, filenames, URLs, or file objects. (See :ref:`Stylesheet Origins`.) :param bool presentational_hints: Whether HTML presentational hints are followed. :param tuple optimize_size: Optimize size of generated PDF. Can contain "images" and "fonts". :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 dict image_cache: A dictionary used to cache images. :returns: A :class:`document.Document` object. )rZ_render)r#Ú stylesheetsÚpresentational_hintsÚ optimize_sizeÚ font_configÚ counter_styleÚ image_cacher.r.r/Úrenderksz HTML.renderr c Cs"|j||||| | d�j||||ƒS)aQRender the document to a PDF file. This is a shortcut for calling :meth:`render`, then :meth:`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 list stylesheets: An optional list of user stylesheets. The list's elements are :class:`CSS` objects, filenames, URLs, or file-like objects. (See :ref:`Stylesheet Origins`.) :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". :param list attachments: A list of additional file attachments for the generated PDF document or :obj:`None`. The list's elements are :class:`Attachment` objects, filenames, URLs or file-like objects. :param finisher: A finisher function, 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. :param bool presentational_hints: Whether HTML presentational hints are followed. :param tuple optimize_size: Optimize size of generated PDF. Can contain "images" and "fonts". :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 dict image_cache: A dictionary used to cache images. :returns: The PDF as :obj:`bytes` if ``target`` is not provided or :obj:`None`, otherwise :obj:`None` (the PDF is written to ``target``). )r:r;r<r=r>)r?Ú write_pdf) r#Útargetr9ZzoomÚ attachmentsZfinisherr:r;r<r=r>r.r.r/r@Šs - zHTML.write_pdf©r8)NFrCNNN©r8) NNr NNFrDNNN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rr0r2r5r7r?r@r.r.r.r/r"s' c@s6eZdZdZdddddddeddddddfdd„ZdS)ra#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. NFrcCsÞtjd|p|pt|ddƒƒt|||||||| d�}|�R\}}}}|dkrbt|tƒ rbtj|ƒ}n$|dkrr|jƒ}tj |||d�\}}WdQRX||_ | p t j ƒ|_ |dkr°gn||_g|_t| ||||j |j|j| | ƒ dS)Nz&Step 2 - Fetching and parsing CSS - %srz CSS string)rr Úcheck_css_mime_typer(r')Zenvironment_encodingr-)rrrrrÚbytesÚtinycss2Zparse_stylesheetÚreadZparse_stylesheet_bytesrr"ZMatcherÚmatcherÚ page_rulesr8Úpreprocess_stylesheet)r#r$r%r&r'r(r)rr Z_check_mime_typer!r<r=rMrNr*r+r,r-Z stylesheetr.r.r/r0Ís,   z CSS.__init__)rErFrGrHrr0r.r.r.r/r¾s c@s*eZdZdZddddddedfdd„ZdS)ra°File attachment for a PDF document. .. versionadded:: 0.22 An instance is created in the same way as :class:`HTML`, except that the HTML specific arguments (``encoding`` and ``media_type``) are not supported. An optional description can be provided with the ``description`` argument. :param description: A description of the attachment to be included in the PDF document. May be :obj:`None`. Nc Cs"t|||||||d�|_||_dS)N)rr )rr,Ú description) r#r$r%r&r'r(rr rPr.r.r/r0ús  zAttachment.__init__)rErFrGrHrr0r.r.r.r/rìs Fc cs(|dk rt|ƒ}dd„|||||fDƒ}t|ƒdkrNtddj|ƒpDdƒ‚�nÖ|dk r¼t|dƒrfd } n"t|tƒrvd } nt|ƒr„d } nd } tf|||d œ| |i—Ž} | � } | VWdQRX�nh|dk �rt|tƒrØt |ƒ}|dkrèt |ƒ}t |d ƒ�}d ||dfVWdQRX�n|dk �r¼t ||ƒ��} |�r`| ddk�r`t jd| d| dƒdd|dfVnP| jdƒ} |dk�r€| jd|ƒ}d| k�ržd| d|| fVnd | d || fVWdQRXnh|dk �r|dk�røt|ddƒ} | �rø| jdƒ �røt| ƒ}d ||dfVn|dk �st‚d||dfVdS)zCIf only one input is given, return it with normalized ``base_url``.NcSsg|]}|dk r|‘qS)Nr.)Ú.0Úparamr.r.r/ú sz"_select_source..r z!Expected exactly one source, got z, ZnothingrLr'r%r&)rr rIÚrbZ mime_typeztext/cssz%Unsupported stylesheet type %s for %sZredirected_urlr(Úr)rú<)rÚlenÚ TypeErrorÚjoinÚhasattrrrrrrr Úopenr rÚerrorÚgetrÚ startswithÚAssertionError) r$r%r&r'r(rr rIZselected_paramsÚtype_r*Zproto_encodingrr.r.r/rsb                 r)rO)r3r1r6r)rr)"rHÚ contextlibZpathlibrr"rrKr r Ú__all__Úurlsr rr rrÚloggerrrrrrÚcontextmanagerrÚcssrOÚhtmlr3r1r6rÚdocumentrrr.r.r.r/Ú s*  .?