
    j5j                       d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZ  ej                  d      Zd	Zd
ZdZdZdZdZdZdZddZddZ	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZdded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)zFValidate that required external programs are installed and new enough.    )annotationsN)CallableMapping)CalledProcessError)Version)MissingDependencyErrorzocrmypdf.subprocesszU
The program '{program}' could not be executed or was not found on your
system PATH.
z
The program '{program}' could not be executed or was not found on your
system PATH.  This program is required when you use the
{required_for} arguments.  You could try omitting these arguments, or install
the package.
z
The program '{program}' could not be executed or was not found on your
system PATH.  This program is recommended when using the {required_for} arguments,
but not required, so we will proceed.  For best results, install the program.
z
OCRmyPDF requires '{program}' {need_version} or higher.  Your system appears
to have {found_version}.  Please update this program.
z
OCRmyPDF requires '{program}' {need_version} or higher when run with the
{required_for} arguments.  {program} {found_version} is installed.

If you omit these arguments, OCRmyPDF may be able to
proceed.  For best results, update the program.
zn
If you have homebrew installed, try these command to install the missing
package:
    brew install {package}
z
On systems with the aptitude package manager (Debian, Ubuntu), try these
commands:
    sudo apt update
    sudo apt install {package}

On RPM-based systems (Red Hat, Fedora), try this command:
    sudo dnf install {package}
z
If not already installed, install the Chocolatey package manager. Then use
a command prompt to install the missing package:
    choco install {package}
c                     t         j                  j                  d      ryt         j                  j                  d      ryt         j                  j                  d      ryt         j                  S )Nfreebsdlinuxwinwindows)sysplatform
startswith     P/var/www/html/qr/venv/lib/python3.12/site-packages/ocrmypdf/subprocess/_check.py_get_platformr   I   sK    
||y)		 	 	)		 	 	'<<r   c                   ~t        |t              r|j                  t               |       }t               dk(  r1t        j                  t        j                  di t                      y t               dk(  r1t        j                  t        j                  di t                      y t               dk(  r1t        j                  t        j                  di t                      y y )Ndarwinr   r   r   )
isinstancer   getr   loginfoOSX_INSTALL_ADVICEformatlocalsLINUX_INSTALL_ADVICEWINDOWS_INSTALL_ADVICE)programpackagekwargss      r   _error_trailerr#   S   s    '7#++mow7("#**6VX67	G	#%,,8vx89	I	%'..::; 
&r   c                V   |r1t         j                  t        j                  di t	                      nc|r1t         j                  t        j                  di t	                      n0t         j                  t        j                  di t	                      t        di t	                y Nr   )	r   warningMISSING_RECOMMEND_PROGRAMr   r   errorMISSING_OPTIONAL_PROGRAMMISSING_PROGRAMr#   )r    r!   required_forrecommendeds       r   _error_missing_programr-   `   sm     -44@vx@A			*11=FH=>		/((46845VXr   c                    |r1t         j                  t        j                  di t	                      n0t         j                  t        j                  di t	                      t        di t	                y r%   )r   r(   OLD_VERSION_REQUIRED_FORr   r   OLD_VERSIONr#   )r    r!   need_versionfound_versionr+   s        r   _error_old_versionr3   m   sM     		*11=FH=>		+$$0vx01VXr   F)r+   r,   version_parserc                   t        |t              s ||      }	  |       }|r3||k  r.t        | |t        |      t        |      |       |st        |       t        j                  d| |       y# t        t        f$ r&}t	        | |||       |st        |       |Y d}~yd}~wt
        $ r t	        | |||       |s Y yw xY w)aE  Check for required version of external program and raise exception if not.

    Args:
        program: The name of the program to test.
        package: The name of a software package that typically supplies this program.
            Usually the same as program.
        version_checker: A callable without arguments that retrieves the installed
            version of program.
        need_version: The minimum required version.
        required_for: The name of an argument of feature that requires this program.
        recommended: If this external program is recommended, instead of raising
            an exception, log a warning and allow execution to continue.
        version_parser: A class that should be used to parse and compare version
            numbers. Used when version numbers do not follow standard conventions.
    NzFound %s %s)
r   r   r   FileNotFoundErrorr-   r   r3   strr   debug)	r    r!   version_checkerr1   r+   r,   r4   r2   es	            r   check_external_programr;   |   s    2 lG,%l3') 5Wc,/]1C\	
 (11IImWm4%  12 w{K(1q8! w{K	s   A. .B>=BB>=B>)returnr7   )r    r7   r!   zstr | Mapping[str, str]r<   None)
r    r7   r!   r7   r+   
str | Noner,   boolr<   r=   )r    r7   r!   r7   r1   r7   r2   r7   r+   r>   r<   r=   )r    r7   r!   r7   r9   zCallable[[], Version]r1   zstr | Versionr+   r>   r,   r?   r4   ztype[Version]r<   r=   )__doc__
__future__r   loggingr   collections.abcr   r   
subprocessr   packaging.versionr   ocrmypdf.exceptionsr   	getLoggerr   r*   r)   r'   r0   r/   r   r   r   r   r#   r-   r3   r;   r   r   r   <module>rH      sC   M "  
 - ) % 6g-.
  
    
<


.8
GK
	
  	
  
*  $$+/5/5 /5 +	/5
  /5 /5 /5 "/5 
/5r   