
    TAi                        S r SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr  SS
KJr   " S S5      r " S S5      rg)zCDefines context objects that are passed to child processes/threads.    )annotationsN)	Namespace)Iterator)copy)Path)PluginManager)PdfInfo)PageInfoc                  z    \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'           SS jrSS jrSS jrSS jr	Sr
g)
PdfContext   z7Holds the context for a particular run of the pipeline.r   optionsr   originr	   pdfinfor   plugin_managerc                @    Xl         X l        X0l        X@l        XPl        g N)r   work_folderr   r   r   )selfr   r   r   r   r   s         P/var/www/html/land-ocr/venv/lib/python3.13/site-packages/ocrmypdf/_jobcontext.py__init__PdfContext.__init__   s     &,    c                     U R                   U-  $ )zGenerate a ``Path`` for an intermediate file involved in processing.

The path will be in a temporary folder that is common for all processing
of this particular PDF.
)r   r   names     r   get_pathPdfContext.get_path*   s     $&&r   c              #  t   #    [        U R                  5      n[        U5       H  n[        X5      v   M     g7f)z%Get all ``PageContext`` for this PDF.Nlenr   rangePageContextr   npagesns      r   get_page_contextsPdfContext.get_page_contexts2   s,     T\\"vAd&& s   68c              #  v   #    [        U R                  5      n[        U5       H  n[        X5      4v   M     g7f)zJGet all ``PageContext`` for this PDF packaged in tuple for args-splatting.Nr    r$   s      r   get_page_context_args PdfContext.get_page_context_args8   s/     T\\"vAt')) s   79)r   r   r   r   r   N)r   r   r   r   r   r   r   r	   r   strreturnr   )r.   zIterator[PageContext])r.   zIterator[tuple[PageContext]])__name__
__module____qualname____firstlineno____doc____annotations__r   r   r'   r*   __static_attributes__ r   r   r   r      sV    AL!!-- - 	-
 -''*r   r   c                  f    \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   SS jrSS jrS rSr	g)r#   ?   zHolds our context for a page.

Must be pickle-able, so stores only intrinsic/simple data elements or those
capable of their serializing themselves via ``__getstate__``.
r   r   r   r   intpagenor
   pageinfor   r   c                    UR                   U l         UR                  U l        UR                  U l        X l        UR                  U   U l        UR                  U l        g r   )r   r   r   r:   r   r;   r   )r   pdf_contextr:   s      r   r   PageContext.__init__L   sO    &22!(("**#++F3)88r   c                F    U R                   U R                  S-   S SU 3-  $ )zGenerate a ``Path`` for a file that is part of processing this page.

The path will be based in a common temporary folder and have a prefix based
on the page number.
   06d_)r   r:   r   s     r   r   PageContext.get_pathT   s+     dkkAos$;1TF"CCCr   c                z   U R                   R                  5       n[        U R                  5      US'   [        US   R                  [
        [        -  [        R                  -  5      (       d
  SUS   l        [        US   R                  [
        [        -  [        R                  -  5      (       d
  SUS   l	        U$ )Nr   stream)
__dict__r   r   
isinstance
input_filer-   bytesosPathLikeoutput_file)r   states     r   __getstate__PageContext.__getstate__\   s    ""$-i%	*55sU{R[[7PQQ*2E)'%	*66ebkk8QRR+3E)(r   )r   r   r;   r:   r   r   N)r=   r   r,   )
r/   r0   r1   r2   r3   r4   r   r   rN   r5   r6   r   r   r#   r#   ?   s5     LK!!9Dr   r#   )r3   
__future__r   rJ   argparser   collections.abcr   r   pathlibr   pluggyr   ocrmypdf.pdfinfor	   ocrmypdf.pdfinfo.infor
   r   r#   r6   r   r   <module>rW      s;    J " 	  $     $ *(* (*V% %r   