
    j5j                        d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
 ddlmZ  ej                  d      Zdd	dd
	 	 	 	 	 	 	 ddZy)z/Extract version strings from external programs.    )annotationsN)PIPESTDOUTCalledProcessError)MissingDependencyError)Environzocrmypdf.subprocessz	--versionz(\d+(\.\d+)*))version_argregexenvc          	        ddl m} | |g}	 |j                  |ddt        t        d|      }|j
                  }t        j                  ||j                               }	|	st        d
|  d|       |	j!                  d      }
|
S # t        $ r}t        d|  d      |d}~wt        $ rU}|j                  dk7  r1t        j                  |       t        d|  d	|j                         |t        d|  d      |d}~ww xY w)ad  Get the version of the specified program.

    Arguments:
        program: The program to version check.
        version_arg: The argument needed to ask for its version, e.g. ``--version``.
        regex: A regular expression to parse the program's output and obtain the
            version.
        env: Custom ``os.environ`` in which to run program.
    r   )
subprocessT)	close_fdstextstdoutstderrcheckr   zCould not find program 'z' on the PATHNzRan program 'z' but it exited with an error:
zThe program 'z+' did not report its version. Message was:
   )ocrmypdfr   runr   r   r   FileNotFoundErrorr   r   
returncodelog	exceptionoutputrematchstripgroup)programr	   r
   r   _sp	args_progprocr   er   versions              R/var/www/html/qr/venv/lib/python3.12/site-packages/ocrmypdf/subprocess/_version.pyget_versionr&      s/   ( ++&Iww  
 kk HHUFLLN+E$G9 %#H&
 	
 kk!nGN-  $&wi}=
	  <<1MM!(y(H
S %&wi}=
	s$   ,B 	C<BC<'AC77C<)r   strr	   r'   r   zEnviron | Nonereturnr'   )__doc__
__future__r   loggingr   r   r   r   r   ocrmypdf.exceptionsr   ocrmypdf.subprocess._runr   	getLoggerr   r&        r%   <module>r1      sh    6 "  	 7 7 6 ,g-. #
88 8
 
8 	8r0   