
    HAi                         S r SrSrSr/ SQrSSKrSSKJr  \R                  r	\R                  r
 " S	 S
\5      rS r\R                  r " S S\5      rS rg)zH
ghostscript - A Python interface for the Ghostscript interpreter C-API
z-Hartmut Goebel <h.goebel@crazy-compilers.com>zDCopyright 2010-2023 by Hartmut Goebel <h.goebel@crazy-compilers.com>z-GNU General Public License version 3 (GPL v3))GhostscriptrevisionGhostscriptErrorPleaseDisplayUsage    N   )_gsprintc                       \ rS rSrSrSrg)r   &   z
This exception is raised when Ghostscript asks the application to
display the usage. The application should catch the exception an
print the usage message.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       P/var/www/html/land-ocr/venv/lib/python3.13/site-packages/ghostscript/__init__.pyr   r   &   s    
 	r   r   c                      [         R                  " 5       n U R                  R                  S5      U R                  R                  S5      U R                  U R
                  S.$ )a  
This function returns the revision numbers and strings of the
Ghostscript interpreter library as a dict. You should call it
before any other interpreter library functions to make sure that
the correct version of the Ghostscript interpreter has been
loaded.
utf-8)product	copyrightr   revisiondate)gsr   r   decoder   r   )revs    r   r   r   /   sO     ++-C ;;%%g.]]))'2LL((	 r   c                   v    \ rS rSr\S 5       rSSSS.S jrS rS rSS jr	S	 r
S
 rSS jrSS jrSS jrSrg)r   D   c                      [        5       $ N)r   r   r   r   r   Ghostscript.revisionE   s
    zr   N)stdinstdoutstderrc                   U R                  5       S   S:  d   S5       eSU l        SU l        [        R                  " 5       U l        [        U[        5      (       d)  SSKnUR                  S[        SS9  U/[        U5      -   nOp[        R                  " U R                  [        R                  5        U Vs/ s H  owR                  S	5      PM     nnUR                  SUR                  S	5      5        US   R                  S
5      (       a  SSKnUR                  S[         SS9   U R#                  X#U5        [        R$                  " U R                  U5      nU[        R&                  :X  a
  [)        5       egs  snf ! [        R*                   a9  n	U R-                  5         U	R.                  [        R0                  :w  a  e  Sn	A	gSn	A	f  U R-                  5         e = f)aI  Initialize a Ghostscript interpreter instance

:param progname: Name of the executable.
:type progname: string
:param args: arguments to be passed to the Ghostscript interpreter
:type args: list of strings

:param stdin: stdin stream to be set for the Ghostscript interpreter
:type stdin: file-like object supporting the ``readline()`` method,
             optional.
:param stdout: stdout stream to be set for the Ghostscript interpreter
:type stdout: file-like object supporting the ``write()`` and
              ``flush()`` methods, optional.
:param stderr: stderr stream to be set for the Ghostscript interpreter
:type stderr: file-like object supporting the ``write()`` and
              ``flush()`` methods, optional.

Example::

  Ghostscript("text2pdf", "-q", "-dNOPAUSE", "-dBATCH", "in.pdf",
              stdout=myIoStream).exit()
r   i  z1high-level interface requires ghostscript >= 9.08Nr   z8Passing bytes-arguments to 'Ghostscript()' is deprecated   )
stacklevelr      -z@First arguments must be the 'progname', but looks like an option)r   
_callbacks	_instancer   new_instance
isinstancestrwarningswarnDeprecationWarninglistset_arg_encodingARG_ENCODING_UTF8encodeinsert
startswithRuntimeWarning	set_stdioinit_with_argse_Infor   r   exitcodee_Quit)
selfprognamer!   r"   r#   argsr-   arces
             r   __init__Ghostscript.__init__I   s   . }}z*c1 	@?	@1*(C((MMJ"q  2 :T
*D0D0DE/34t!HHW%tD4KK8??7347d##MM 5(Q  8	NN5&1""4>>48BRYY(**  5 "" 	IIKvv" #	IIKs   8E:(AE? ?G/GGc                     U $ r   r   r=   s    r   	__enter__Ghostscript.__enter__   s    r   c                 $    U R                  5         g r   r:   )r=   r?   s     r   __exit__Ghostscript.__exit__       		r   c                 ~   U(       d  U(       d  U(       d  gU=(       a    [         R                  " U5      =(       d    SU=(       a    [         R                  " U5      =(       d    SU=(       a    [         R                  " U5      =(       d    S4U l        [         R
                  " U R                  /U R                  Q76   g)a  Set stdin, stdout and stderr of the ghostscript interpreter.

The ``stdin`` stream has to support the ``readline()``
interface. The ``stdout`` and ``stderr`` streams have to
support the ``write()`` and ``flush()`` interface.

Please note that this does not affect the input- and output-
streams of the devices. Esp. setting stdout does not allow
catching the devise-output even when using ``-sOutputFile=-``.

N)r   _wrap_stdin_wrap_stdout_wrap_stderrr(   r7   r)   )r=   r!   r"   r#   s       r   r7   Ghostscript.set_stdio   sv     VF +bnnU+3t.rv.6$.rv.6$
 	T^^6doo6r   c                 $    U R                  5         g r   rJ   rF   s    r   __del__Ghostscript.__del__   rM   r   c                     U R                   (       aI   [        R                  " U R                   5        [        R                  " U R                   5        S U l         g g ! S U l         f = fr   )r)   r   r:   delete_instancerF   s    r   r:   Ghostscript.exit   sG    >>&'""4>>2!% 
 "&s   A A 	A%c                 J   U R                   n[        U5      [        :  a  [        R                  " X15        g[        R
                  " U5        [        S[        U5      [        5       H#  n[        R                  " UXU[        -    5        M%     [        R                  " U5        g)z
Run the string ``str`` by Ghostscript

This takes care of Ghostscripts size-limitations and passes
the string in pieces if necessary.
r   N)	r)   lenMAX_STRING_LENGTHr   
run_stringrun_string_beginrangerun_string_continuerun_string_end)r=   r,   user_errorsinstancestarts        r   r\   Ghostscript.run_string   s{     >>s8''MM(()q#c(,=>&&x'*7H1H'IK ? h'r   c                 D    [         R                  " U R                  X5      $ )z3
Run the file named by ``filename`` by Ghostscript
)r   run_filer)   )r=   filenamera   s      r   run_filenameGhostscript.run_filename   s     {{4>>8AAr   c                     U R                   n[        R                  " U5         UR                  [        5      nU(       d  O[        R
                  " X45        M5  [        R                  " U5        g)z
Read ``file`` and run the content by Ghostscript.

``file`` must already by opened and may by any file-like
object supporting the ``read()`` method.
N)r)   r   r]   readr[   r_   r`   )r=   filera   rb   r,   s        r   rf   Ghostscript.run_file   sV     >>
H%))-.C""81	 
 	(#r   )r(   r)   )NNN)F)r   r   r   r   staticmethodr   rC   rG   rK   r7   rT   r:   r\   rh   rf   r   r   r   r   r   r   D   sL      /34 7r7,&("B$r   r   c                      g)z!Does nothing anymore. Deprecated.Nr   r   r   r   cleanuprp      s    r   )r   
__author____copyright____licence____all__sys r   r   __version__r   Warningr   r   r[   objectr   rp   r   r   r   <module>rz      sr   * =
V=5  nn&& 	 	$ (( J$& J$Z	r   