§
    ¥”j™  ã                   óØ   — d Z ddlZddlZddlZddlmZ ddlmZm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 	  ed	¦  «        Zn# e$ r d
ZY nw xY wddedee         ddfd„Zdd„ZdS )aš  A tool for converting SVG to PDF.

This module provides a high-level function for converting SVG files to PDF format
using the ReportLab graphics library. It also serves as the main entry point for
the svglib package.

The module includes:
- svg2pdf(): Convert SVG files to PDF programmatically.
- main(): Command-line interface for SVG to PDF conversion.
- Automatic file path handling and output generation.
é    N)Údatetime)ÚPackageNotFoundErrorÚversion)ÚbasenameÚdirnameÚexistsÚsplitext)ÚOptional)Ú	renderPDF)Úsvglibr   ÚunknownÚpathÚ	outputPatÚreturnc                 ó�  — t          | ¦  «        pdt          | ¦  «        t          t          | ¦  «        d         ¦  «        t          | ¦  «        d         t          j        ¦   «         ddœ}|pd}||z  } |j        d
i |¤Ž}	 t          j        | ¦  «        }n#  t          d¦  «         ‚ xY w|rt          j
        ||d¬¦  «         d	S d	S )a  Convert an SVG file to PDF format.

    High-level function that loads an SVG file, converts it to a ReportLab drawing,
    and saves it as a PDF file. Supports both .svg and .svgz (compressed SVG) files.

    Args:
        path: Path to the input SVG file (.svg or .svgz extension).
        outputPat: Optional output path pattern. Supports placeholders:
            - %(dirname)s: Directory of input file
            - %(basename)s: Full filename with extension
            - %(base)s: Filename without extension
            - %(ext)s: File extension
            - %(now)s: Current datetime object
            - %(format)s: Output format (always "pdf")
            Also supports {name} format strings.

    Returns:
        None. The PDF file is written to disk.

    Raises:
        FileNotFoundError: If the input SVG file does not exist.
        Exception: If SVG parsing or PDF generation fails.
        OSError: If the output directory is not writable.

    Examples:
        Basic conversion:
        >>> svg2pdf("input.svg")  # Creates "input.pdf"

        Custom output location:
        >>> svg2pdf("input.svg", "output.pdf")

        Using placeholders:
        >>> svg2pdf("path/file.svg", "%(dirname)s/converted/%(base)s.pdf")
        # Creates "path/converted/file.pdf"

        Timestamped output:
        >>> svg2pdf("file.svg", "backup/%(now.year)s-%(now.month)s-%(base)s.pdf")

    Note:
        The function will overwrite existing PDF files without warning.
        For compressed SVG files (.svgz), the file is automatically decompressed.
    ú.r   é   Úpdf)r   r   ÚbaseÚextÚnowÚformatz%(dirname)s/%(base)s.%(format)szRendering failed.)ÚshowBoundaryN© )r   r   r	   r   r   r   r   Úsvg2rlgÚprintr   Ú
drawToFile)r   r   Ú	file_infoÚout_patternÚout_pathÚdrawings         ú^/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/svglib/__init__.pyÚsvg2pdfr#      sì   € õ\ ˜4‘=”=Ð' CÝ˜T‘N”NÝ� $™œ¨Ô*Ñ+Ô+Ý˜‰~Œ~˜aÔ ÝŒ|‰~Œ~Øðð €Ið Ð@Ð@€Kà˜YÑ&€HàˆxŒÐ+Ð+ Ð+Ð+€HðÝ”. Ñ&Ô&ˆˆøðÝÐ!Ñ"Ô"Ð"Øøøøð ð @ÝÔ˜W h¸QÐ?Ñ?Ô?Ð?Ð?Ð?ð@ð @s   ÂB ÂB(c                  óh  — d} |                       ¦   «         }t          t          t          j        d         ¦  «        t
          d| |¬¦  «        }|dxx         d|d         z  z  cc<    dj        di |¤Ž}|d	                     |¦  «        z  }t          j         d
j        di |¤Ž¦  «        }t          j
        ||t          j        ¬¦  «        }|                     dddd¬¦  «         |                     dddd¬¦  «         |                     dddd¬¦  «         |                     ¦   «         }|j        r't          t
          ¦  «         t          j        ¦   «          |j        s'|                     ¦   «          t          j        ¦   «          d„ |j        D ¦   «         }|D ]}t'          ||j        ¬¦  «         ŒdS )zMain entry point for the CLI.r   r   zC{{dirname}}/out-{{now.hour}}-{{now.minute}}-{{now.second}}-%(base)s)Úprogr   Ú
ts_patternr   Úext_capsr&   z.%sr   z{prog} v. {version}
z4A converter from SVG to {} (via ReportLab Graphics)
aÒ          examples:
          # convert path/file.svg to path/file.{ext}
          {prog} path/file.svg

          # convert file1.svg to file1.{ext} and file2.svgz to file2.{ext}
          {prog} file1.svg file2.svgz

          # convert file.svg to out.{ext}
          {prog} -o out.{ext} file.svg

          # convert all SVG files in path/ to PDF files with names like:
          # path/file1.svg -> file1.{ext}
          {prog} -o "%(base)s.{ext}" path/file*.svg

          # like before but with timestamp in the PDF files:
          # path/file1.svg -> path/out-12-58-36-file1.{ext}
          {prog} -o {ts_pattern} path/file*.svg

        issues/pull requests:
            https://github.com/deeplook/svglib
        )ÚdescriptionÚepilogÚformatter_classz-vz	--versionzPrint version number and exit.Ú
store_true)ÚhelpÚactionz-oz--outputÚPATH_PATzsSet output path (incl. the placeholders: dirname, basename,base, ext, now) in both, %%(name)s and {name} notations.)Úmetavarr,   ÚinputÚPATHÚ*z1Input SVG file path with extension .svg or .svgz.)r/   Únargsr,   c                 ó0   — g | ]}t          |¦  «        ¯|‘ŒS r   )r   )Ú.0Úas     r"   ú
<listcomp>zmain.<locals>.<listcomp>²   s#   € Ð0Ð0Ð0�1¥f¨Q¡i¤iÐ0ˆQÐ0Ð0Ð0ó    )r   Nr   )ÚupperÚdictr   ÚsysÚargvÚ__version__r   ÚtextwrapÚdedentÚargparseÚArgumentParserÚRawDescriptionHelpFormatterÚadd_argumentÚ
parse_argsr   r   Úexitr0   Úprint_usager#   Úoutput)	r   r'   Úformat_argsÚdescr)   ÚpÚargsÚpathsr   s	            r"   ÚmainrM   g   s  € à
€CØ�yŠy‰{Œ{€HÝÝ•c”h˜q”kÑ"Ô"Ýðð Øðñ ô €Kð �ÐÐÔ ¨°UÔ);Ñ!;Ñ;ÐÐÑØ)Ð"Ô)Ð8Ð8¨KÐ8Ð8€DØÐC×JÒJÈ8ÑTÔTÑT€DÝŒ_ð	ð 	ô* ð+	"ð 	"ð* !ð+	"ð 	"ñô €Fõ0 	ÔØØÝ Ô<ð	ñ 	ô 	€Að ‡N‚NØˆkÐ @Èð ñ ô ð ð ‡N‚NØØØðCð	 ñ ô ð ð ‡N‚NØØØØ@ð	 ñ ô ð ð �<Š<‰>Œ>€Dà„|ð Ý�kÑÔÐÝŒ‰
Œ
ˆ
àŒ:ð Ø	�Š‰ŒˆÝŒ‰
Œ
ˆ
à0Ð0˜œ
Ð0Ñ0Ô0€EØð -ð -ˆÝ� ¤Ð,Ñ,Ô,Ð,Ð,ð-ð -r8   )N)r   N)Ú__doc__r@   r;   r>   r   Úimportlib.metadatar   r   Úos.pathr   r   r   r	   Útypingr
   Úreportlab.graphicsr   r   r=   Ústrr#   rM   r   r8   r"   ú<module>rT      sQ  ðð
ð 
ð €€€Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø Ð Ð Ð Ð Ð à (Ð (Ð (Ð (Ð (Ð (à Ð Ð Ð Ð Ð ðØ�'˜(Ñ#Ô#€K€KøØð ð ð Ø€K€K€KðøøøðD@ð D@�#ð D@ (¨3¤-ð D@¸4ð D@ð D@ð D@ð D@ðPM-ð M-ð M-ð M-ð M-ð M-s   ¼A ÁAÁA