
    kh!              
          d dl mZmZmZmZmZmZmZ d dlZd dl	Z	d dl
Z
d dlZd dlmZ  e
j                  e      Zej$                  dk  rd dlZnd dlmZ ej,                  j/                  d      duZ	  ej2                  d      Zej7                  de d       ej,                  j/                  d	      duZ	  ej2                  d	      Zej7                  d
e d       ej,                  j/                  d      duZ	  ej2                  d      Z ej7                  de  d       ej,                  j/                  d      duZ!	  ej2                  d      Z"ej7                  de" d       ej,                  j/                  d      duZ#	  ej2                  d      Z$ej7                  de$ d       	 ej,                  j/                  d      duZ%	  ej2                  d      Z&ej7                  de& d       d Z(d Z)d Z*d Z+d Z,d Z-d Z.dZ/dZ0dZ1d Z2d!Z3d"Z4 e5de(e/ffd	e*e0ffde+e1ffde,e2ffde-e3ffde.e4ffg      Z6d# Z7 G d$ d%e      Z8y# ej8                  $ r dZY w xY w# ej8                  $ r dZY w xY w# ej8                  $ r dZY jw xY w# ej8                  $ r dZ"Y =w xY w# ej8                  $ r dZ#Y w xY w# ej8                  $ r dZ%Y w xY w# e'$ r dZ%Y w xY w)&    )AnyBinaryIODictListOptionalTupleUnionN)
ModuleType)      torchzPyTorch version z available.F
detectron2zDetectron2 version z
 availablepaddlepaddlepaddlezPaddle version effdetzEffdet version pytesseractzPytesseract version zgoogle.cloud.visionzgoogle-cloud-visionz"Google Cloud Vision Utils version c                      t         S N)_torch_available     S/var/www/teggl/fontify/venv/lib/python3.12/site-packages/layoutparser/file_utils.pyis_torch_availabler   \   s    r   c                  T    t               rdd l} | j                  j                         S y)Nr   F)r   r   cudais_available)r   s    r   is_torch_cuda_availabler   `   s!    zz&&((r   c                      t         S r   )_detectron2_availabler   r   r   is_detectron2_availabler    i   s      r   c                      t         S r   )_paddle_availabler   r   r   is_paddle_availabler#   m       r   c                      t         S r   )_effdet_availabler   r   r   is_effdet_availabler'   q   r$   r   c                      t         S r   )_pytesseract_availabler   r   r   is_pytesseract_availabler*   u   s    !!r   c                      t         S r   )_gcv_availabler   r   r   is_gcv_availabler-   y   s    r   z
{0} requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.
a  
{0} requires the detectron2 library but it was not found in your environment. Checkout the instructions on the
installation page: https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md and follow the ones
that match your environment. Typically the following would work for MacOS or Linux CPU machines:
    pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2' 
z
{0} requires the PaddlePaddle library but it was not found in your environment. Checkout the instructions on the
installation page: https://github.com/PaddlePaddle/Paddle and follow the ones that match your environment.
z}
{0} requires the effdet library but it was not found in your environment. You can install it with pip:
`pip install effdet`
z
{0} requires the PyTesseract library but it was not found in your environment. You can install it with pip:
`pip install pytesseract`
z
{0} requires the Google Cloud Vision Python utils but it was not found in your environment. You can install it with pip:
`pip install google-cloud-vision==1`
c           
      B   t        |t        t        f      s|g}t        | d      r| j                  n| j
                  j                  }t        d |D              sAt        dj                  |D cg c]  }t        |   d   j                  |       c}            y c c}w )N__name__c              3   <   K   | ]  }t        |   d             yw)r   N)BACKENDS_MAPPING).0backends     r   	<genexpr>z$requires_backends.<locals>.<genexpr>   s     F'(+-Fs       )
isinstancelisttuplehasattrr/   	__class__allImportErrorjoinr1   format)objbackendsnamer3   s       r   requires_backendsrC      s    hu.:"3
33<<9O9ODFXFFGGhW7%g.q188>WX
 	
 GWs   ."Bc                   R     e Zd ZdZ	 d
 fd	Z fdZdedefdZdefdZ	d	 Z
 xZS )_LazyModulezu
    Module class that surfaces all objects but only performs associated imports when the objects are requested.
    c                    t         	|   |       t        |j                               | _        i | _        |j                         D ]  \  }}|D ]  }|| j
                  |<     t        |j                               t        |j                         g       z   | _
        || _        || _        t        j                  j                  |      g| _        |i n|| _        || _        || _        | j(                  | _        y r   )super__init__setkeys_modules_class_to_moduleitemsr8   sumvalues__all____file____spec__ospathdirname__path___objects_name_import_structurer/   __package__)
selfrB   module_fileimport_structuremodule_specextra_objectskeyrO   valuer;   s
            r   rH   z_LazyModule.__init__   s     	,1134 "+113 	3KC 3/2%%e,3	3 ,1134s##%r8
 
 $#56+3
!1
  ==r   c                 :    t         |          | j                  z   S r   )rG   __dir__rP   )r[   r;   s    r   rc   z_LazyModule.__dir__   s    w 4<<//r   rB   returnc                 ^   || j                   v r| j                   |   S || j                  v r| j                  |      }nb|| j                  j	                         v r+| j                  | j                  |         }t        ||      }nt        d| j                   d|       t        | ||       |S )Nzmodule z has no attribute )	rW   rK   _get_modulerL   rJ   getattrAttributeErrorr/   setattr)r[   rB   ra   modules       r   __getattr__z_LazyModule.__getattr__   s    4== ==&&4== $$T*ET**//11%%d&;&;D&ABFFD)E 74==/9KD6!RSSdE"r   module_namec                 H    t        j                  d|z   | j                        S )N.)	importlibimport_moduler/   )r[   rl   s     r   rf   z_LazyModule._get_module   s    &&s['8$--HHr   c                 `    | j                   | j                  | j                  | j                  ffS r   )r;   rX   rQ   rY   )r[   s    r   
__reduce__z_LazyModule.__reduce__   s&    T]]D<R<R STTr   )NN)r/   
__module____qualname____doc__rH   rc   strr   rk   rf   rr   __classcell__)r;   s   @r   rE   rE      s@     TX)40  Is IUr   rE   )9typingr   r   r   r   r   r   r	   sysrS   loggingimportlib.utilro   typesr
   	getLoggerr/   loggerversion_infoimportlib_metadataimportlib.metadatametadatautil	find_specr   version_torch_versiondebugPackageNotFoundErrorr   _detectron2_versionr"   _paddle_versionr&   _effdet_versionr)   _pytesseract_versionr,   _gcv_versionModuleNotFoundErrorr   r   r    r#   r'   r*   r-   PYTORCH_IMPORT_ERRORDETECTRON2_IMPORT_ERRORPADDLE_IMPORT_ERROREFFDET_IMPORT_ERRORPYTESSERACT_IMPORT_ERRORGCV_IMPORT_ERRORdictr1   rC   rE   r   r   r   <module>r      s  $ E D D 
 	   			8	$ f3 >>++G4D@ /'//8N
LL#N#3;?@ "00>dJ "4,44\B
LL&':&;:FG NN,,X6dB  1(00@O
LL??"3;?@ NN,,X6dB 0(00:O
LL??"3;?@ #11-@L #5-55mD
LL'(<'=[IJ
^^--.CDDPN1)11!
 	9,{ST!" 
  
 
 
 
 	%';<=	/1HIJ	')<=>	')<=>	13KLM	!13C DE	 
7U* 7UW ..  .. "!" ..  .. O .. #"# 22  Ns   3'I
 8'I" ='I: 'J 'J* /K 'K 
II"I76I7:JJJ'&J'*J?>J?KK KK K#"K#