
    3vj0$                     T   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m	Z	m
Z
 ddlmZ ddlmZ ddlmZ  G d d	ej"                        Z G d
 dej&                        Z edd      Zej-                  dd       ej-                  dd       ej-                  ddedd       ej-                  ddde
 d       ej/                  d      Zej-                  ddd d!d"#       ej-                  d$d%d d&d'#       ej-                  d(d d)d*#       ej-                  d+d,       ej-                  d-ed./       ej-                  d0d1       ej-                  d2d3d45       ej-                  d6d3d75       ej-                  d8d3d95       ej-                  d:d d;5       ej-                  d<d3d=5       ej-                  d>d?       ej-                  d@dAd3dB5       ej-                  dCd3dD5       ej-                  dEdFedGH       ej-                  dIdJedKH       ej-                  dLd3dM5       ej-                  dNd3dO5       ej-                  dPdQdRdST       ej/                  dU      Zej-                  dVdWdX       ej-                  dYdZd[d\]       ej-                  d^d_d`       ej/                  da      Zej-                  dbdceddH       ej-                  dedfdgT       ej-                  dhd3di5       ej-                  djd3dk5       ej/                  dl      Zej5                         Zej-                  dmdnd3do5       ej-                  dpdqd3dr5       ej-                  dsdtd3du5        ej6                  dyi e dddefdvZexj                   dwej:                  z   z  c_         edxk(  r e        yy)zz%Command-line interface to WeasyPrint.    N   )DEFAULT_OPTIONSHTMLLOGGER__version__)VARIANTS)pango)
URLFetcherc                       e Zd Zd Zy)	PrintInfoc                     t        j                         }t        d|j                         t        d|j                         t        d|j
                         t        d|j                         t                t        dt               t        dt        j
                  j                         d          t        dt        j                         t        d	t        j                                t        j                          y )
NzSystem:zMachine:zVersion:zRelease:zWeasyPrint version:zPython version:r   zPydyf version:zPango version:)platformunameprintsystemmachineversionreleaser   syssplitpydyfr	   pango_versionexit)___r   s      F/root/.hermes/venv/lib/python3.12/site-packages/weasyprint/__main__.py__call__zPrintInfo.__call__   s      i&j%--(j%--(j%--(#[1!2!2!4Q!78 1 12 3 3 56
    N)__name__
__module____qualname__r    r   r   r   r      s    r   r   c                   H     e Zd Z fdZdd fd
Z fdZed        Z xZS )Parserc                 6    d i i| _         t        |   |i | y )N)_groupssuper__init__)selfargskwargs	__class__s      r   r(   zParser.__init__"   s     bz$)&)r   N)_group_namec                    |t        |   |i | |d   j                  d      }||d<   |d   d   dk7  |d<   || j                  |   |<   y )N-flagsr   
positional)r'   add_argumentlstripr&   )r)   r-   r*   r+   keyr,   s        r   r3   zParser.add_argument&   s`    G $1&12hooc"w#Bx{c1|)/[!#&r   c                      t           g|i |i  j                  <    fd}j                  _        |_        S )Nc                  R     j                   | i |  j                  | di| y )Nr-   )_add_argumentr3   )r*   r+   groupnamer)   s     r   r3   z/Parser.add_argument_group.<locals>.add_argument1   s2    E00Dt@@@r   )r'   add_argument_groupr&   r3   r8   )r)   r:   r*   r+   r3   r9   r,   s   ``   @r   r;   zParser.add_argument_group.   sM    *4A$A&AT	A $00)r   c           	      H   | j                   d    j                  d       g }| j                   j                         D ]T  \  }}|s
|rJ|j                  |d   j	                          |dd   d       |j                  dt        |      z   d       |j                         D ]  \  }}|j                  d       |j                  dd	      }|d
   D ]B  }|j                  |       |d   s|dv r|j                  d| d       |j                  d       D d|d<   |j                  d|d   d   j                          |d   dd   d       d|v r)dj                  |d         }|j                  d| d       |dk(  s|j                  d        W dj                  |      S )Nhelpr   r   
~

z.. option:: actionstorer1   r2   )rB   appendz <>z, r/   z  z.

choicesz  Possible choices: rC   z-  This option can be passed multiple times.

 )	r&   popitemsrC   titlelengetupperjoin)	r)   datar9   	argumentsr5   r*   rA   flagrE   s	            r   	docstringzParser.docstring8   s   Tv& $ 2 2 4 	SE9uQx~~/0qr2>?sSZ/056&__. S	TN+(G4 M &DKK%-&<O2ObQK0KK%	&
 "Rbfa!6!6!8 9$v,qr:J9K5QR$"iiY8GKK"6wiu EFX%KK QRS	S* wwt}r   )	r   r    r!   r(   r3   r;   propertyrQ   __classcell__)r,   s   @r   r$   r$   !   s+    * /3 0  r   r$   
weasyprintzRender web pages to PDF.)progdescriptioninputz1URL or filename of the HTML input, or - for stdin)r=   outputz1filename where output is written, or - for stdoutz-iz--infoz!print system information and exit)rA   nargsr=   z	--versionr   zWeasyPrint version u,   print WeasyPrint’s version number and exit)rA   r   r=   zrendering optionsz-sz--stylesheetrC   stylesheetsz)URL or filename for a user CSS stylesheet)rA   destr=   z-az--attachmentattachmentsz7URL or filename of a file to attach to the PDF documentz--attachment-relationshipattachment_relationshipsz8Relationship of the attachment file to attach to the PDFz--pdf-identifierzPDF file identifierz--pdf-variantzPDF variant to generate)rE   r=   z--pdf-versionzPDF version numberz--pdf-forms
store_truezinclude PDF forms)rA   r=   z
--pdf-tagsztag PDF for accessibilityz--uncompressed-pdfz9do not compress PDF content, mainly for debugging purposez--xmp-metadataz:URL or filename of a file to include into the XMP metadataz--custom-metadataz-include custom HTML meta tags in PDF metadataz--output-intentzEsrgb, device-cmyk, or CSS identifier of the output intent color spacez-pz--presentational-hintsz follow HTML presentational hintsz--optimize-imagesz5optimize size of embedded images with no quality lossz-jz--jpeg-qualityz+JPEG quality between 0 (worst) to 95 (best))typer=   z-Dz--dpiz4set maximum resolution of images embedded in the PDFz--full-fontsz)embed unmodified font files when possiblez	--hintingz*keep hinting information in embedded fontsz-cz--cache-foldercachezistore cache on disk instead of memory, folder is created if needed and cleaned after the PDF is generated)r[   r=   zHTML optionsz-ez
--encodingz"force the input character encodingz-mz--media-typez/media type to use for @media, defaults to printr   )r=   defaultz-uz
--base-urluz   base for relative URLs in the HTML input, defaults to the input’s own filename or URL or the current directory for stdinzURL fetcher optionsz-tz	--timeoutz(set timeout in seconds for HTTP requestsz--allowed-protocolsallowed_protocolszBonly authorize comma-separated list of protocols for fetching URLsz--no-http-redirectszdo not follow HTTP redirectsz--fail-on-http-errorsz*abort document rendering on any HTTP errorzcommand-line logging optionsz-vz	--verbosez&show warnings and information messagesz-dz--debugzshow debugging messagesz-qz--quietzhide logging messagesc                    t         j                  |       }|j                  dk(  rI|xs t        j                  j
                  }|j                  d|_        n#|j                  dk(  rd|_        n|j                  }|j                  dk(  r|xs t        j                  j
                  }n|j                  }i }|j                  |j                  |d<   |j                  H|j                  j                  d      D ch c]   }|j                         j                         " c}|d<   |j                  rd|d	<   |j                  rd
|d<   t!        di |}	t#        |      j%                         D 
ci c]  \  }
}|
t&        v s|
| }}
}|j(                  s|j*                  r$t-        j.                  t0        j2                         n/|j4                  r#t-        j.                  t0        j6                         t1        j8                  |j*                  rdnd|j*                  rt0        j2                  nd        |||j                  |j:                  |j<                  |	      } |j>                  |fi | yc c}w c c}}
w )zThe ``weasyprint`` program takes at least two arguments:

    .. code-block:: sh

        weasyprint [options] <input> <output>

    r0   N.rF   timeout,rb   Fallow_redirectsTfail_on_errorszK%(levelname)s: %(name)s %(filename)s:%(lineno)d (%(funcName)s): %(message)sz%(levelname)s: %(message)s)formatlevel)base_urlencoding
media_typeurl_fetcherr"   ) PARSER
parse_argsrW   r   stdinbufferrk   rX   stdoutre   rb   r   striplowerno_http_redirectsfail_on_http_errorsr
   varsrH   r   quietdebugr   setLevelloggingDEBUGverboseINFObasicConfigrl   rm   	write_pdf)argvrs   rq   r   r*   sourcerX   fetcher_argsprotocolrn   r5   valueoptionshtmls                 r   mainr      s    T"DzzS*#))**== DM]]b  DM{{c,3::,,L||"&,,Y)595K5K5Q5QRU5V-X)1HNN""$-X()*/&')-%&,|,K &*$Z%5%5%7S!sE3/;QU
SG S ::::OOGMM*\\OOGLL) zz*;#'::'--4		9 ??=D DNN6%W%3-XSs   :%I2.I7?I7r@   __main__r"   )__doc__argparser|   r   r   r   rF   r   r   r   r   pdfr   text.ffir	   urlsr
   Actionr   ArgumentParserr$   ro   r3   r;   r9   intadd_mutually_exclusive_groupset_defaultsr   rQ   r   r"   r   r   <module>r      s   +    
  8 8    "0X$$ 0f 
\/I	J   G"U  V   H#V  W   (9A4W  Y   	-@+N	7  9 	!!"56   .	4  6   .	B  D   7Q	C  E   %,A  B   ?H;T  U   ?)=  >   =<O  P   <;V  W   	D  F   X	E  G   	8  :   	P  R   
"<	+  -   	@  B   
	6  8   '	?  A   <	4  6   +W  Y   

?  @
 	!!.1   4,P  Q   .P     ,
G  H
 	!!"78   +C&P  R    3	M  O   ,5S  U   L	5  7 	!!"@A**,   +l	1  3   )L/H  J   4<>U  V    &o & 4t$ 5&p ))) ) zF r   