Ë
    ìì�iÈ*  ã                   ó   — d Z ddlZddlZddlZddlZddlZddlZddlZddlZdZ	g d¢Z
 ej                  «       Zdd„Z G d„ dej                  «      Zddd	œd
„Zdedefd„Z G d„ dej(                  «      Zdedefd„Zy)zU
lazy_loader
===========

Makes it easy to load subpackages and functions on demand.
é    Nz0.4)ÚattachÚloadÚattach_stubc                 ó¨  ‡ ‡‡‡	— |€i }‰€t        «       Šnt        ‰«      Š|j                  «       D ���ci c]  \  }}|D ]  }||“Œ Œ c}}}Š	t        ‰‰	j                  «       z  «      Šˆ	ˆ ˆfd„}ˆfd„}t        j
                  j                  dd«      r)t        ‰	j                  «       «      ‰z  D ]
  } ||«       Œ ||t        ‰«      fS c c}}}w )a8  Attach lazily loaded submodules, functions, or other attributes.

    Typically, modules import submodules and attributes as follows::

      import mysubmodule
      import anothersubmodule

      from .foo import someattr

    The idea is to replace a package's `__getattr__`, `__dir__`, and
    `__all__`, such that all imports work exactly the way they would
    with normal imports, except that the import occurs upon first use.

    The typical way to call this function, replacing the above imports, is::

      __getattr__, __dir__, __all__ = lazy.attach(
        __name__,
        ['mysubmodule', 'anothersubmodule'],
        {'foo': ['someattr']}
      )

    This functionality requires Python 3.7 or higher.

    Parameters
    ----------
    package_name : str
        Typically use ``__name__``.
    submodules : set
        List of submodules to attach.
    submod_attrs : dict
        Dictionary of submodule -> list of attributes / functions.
        These attributes are imported as they are used.

    Returns
    -------
    __getattr__, __dir__, __all__

    c                 ó  •— | ‰v rt        j                  ‰› d| › �«      S | ‰v rW‰› d‰|    › �}t        j                  |«      }t        || «      }| ‰|    k(  r"t        j                  ‰   }||j
                  | <   |S t        d‰› d| › �«      ‚)Nú.zNo z attribute )Ú	importlibÚimport_moduleÚgetattrÚsysÚmodulesÚ__dict__ÚAttributeError)ÚnameÚsubmod_pathÚsubmodÚattrÚpkgÚattr_to_modulesÚpackage_nameÚ
submoduless        €€€úy/var/www/ITT-ServiceAPI-Services/ITT-Document-Scan/mrzscanner/mrzenv/lib/python3.12/site-packages/lazy_loader/__init__.pyÚ__getattr__zattach.<locals>.__getattr__M   s©   ø€ Ø�:ÑÜ×*Ñ*¨l¨^¸1¸T¸FÐ+CÓDÐDØ�_Ñ$Ø)˜N¨!¨O¸DÑ,AÐ+BÐCˆKÜ×,Ñ,¨[Ó9ˆFÜ˜6 4Ó(ˆDð
 � tÑ,Ò,Ü—k‘k ,Ñ/�Ø%)�—‘˜TÑ"àˆKä  3 | n°KÀ¸vÐ!FÓGÐGó    c                  ó   •— ‰ S ©N© )Ú__all__s   €r   Ú__dir__zattach.<locals>.__dir__`   s   ø€ Øˆr   ÚEAGER_IMPORTÚ )ÚsetÚitemsÚsortedÚkeysÚosÚenvironÚgetÚlist)
r   r   Úsubmod_attrsÚmodÚattrsr   r   r   r   r   s
   ``      @@r   r   r      sâ   û€ ðN ÐØˆàÐÜ“U‰
ä˜“_ˆ
ð %1×$6Ñ$6Ó$8÷ð Ù �c˜5ÀUòØ=Aˆˆc‰	ðØô€Oô �Z /×"6Ñ"6Ó"8Ñ8Ó9€GöHô&ô 
‡z�z‡~�~�n bÔ)Ü˜×,Ñ,Ó.Ó/°*Ñ<ò 	ˆDÙ˜Õð	ð ˜¤ g£Ð.Ð.ùôAs   µCc                   ó(   ‡ — e Zd Zˆ fd„Zˆ fd„Zˆ xZS )ÚDelayedImportErrorModulec                ó@   •— || _         || _        t        ‰| �  |i |¤Ž y r   )Ú%_DelayedImportErrorModule__frame_dataÚ"_DelayedImportErrorModule__messageÚsuperÚ__init__)ÚselfÚ
frame_dataÚmessageÚargsÚkwargsÚ	__class__s        €r   r3   z!DelayedImportErrorModule.__init__k   s$   ø€ Ø&ˆÔØ ˆŒÜ‰Ñ˜$Ð) &Ó)r   c                 óä   •— |dv rt         ‰| �  |«       y | j                  }t        | j                  › d|d   › d|d   › d|d   › dd	j                  |d
   xs d	«      j                  «       › �	«      ‚)N)r9   Ú__file__Ú__frame_dataÚ	__messagezE

This error is lazily reported, having originally occured in
  File Úfilenamez, line Úlinenoz, in Úfunctionz

----> r!   Úcode_context)r2   r   r0   ÚModuleNotFoundErrorr1   ÚjoinÚstrip)r4   ÚxÚfdr9   s      €r   r   z$DelayedImportErrorModule.__getattr__p   s�   ø€ ØÐFÑFÜ‰GÑ Õ"à×"Ñ"ˆBÜ%Ø—>‘>Ð"ð #à˜Z™.Ð)¨°°H±°¸eÀBÀzÁNÐCSð TØŸ™  NÑ!3Ò!9°rÓ:×@Ñ@ÓBÐCðEóð r   )Ú__name__Ú
__module__Ú__qualname__r3   r   Ú__classcell__)r9   s   @r   r.   r.   j   s   ø„ ô*÷

ð 
r   r.   F)ÚrequireÚerror_on_importc                óp  — t         5  t        j                  j                  | «      }|du}|r|€|cddd«       S d| v rd}t	        j
                  |t        «       d}|s#t        j                  j                  | «      }|du}|sd| › d�}n|�	 t        |«      }d|› d�}|sl|rt        «      ‚d	dl}		 |	j                  «       d
   }
|
j                  |
j                   |
j"                  |
j$                  dœ}t'        |d¬«      ~
cddd«       S |�lt        j                  j)                  |«      }|t        j                  | <   t        j                  j+                  |j,                  «      }|j/                  |«       ddd«       |S # t        $ r}t        d| › d�«      |‚d}~ww xY w# ~
w xY w# 1 sw Y   S xY w)a  Return a lazily imported proxy for a module.

    We often see the following pattern::

      def myfunc():
          import numpy as np
          np.norm(...)
          ....

    Putting the import inside the function prevents, in this case,
    `numpy`, from being imported at function definition time.
    That saves time if `myfunc` ends up not being called.

    This `load` function returns a proxy module that, upon access, imports
    the actual module.  So the idiom equivalent to the above example is::

      np = lazy.load("numpy")

      def myfunc():
          np.norm(...)
          ....

    The initial import time is fast because the actual import is delayed
    until the first attribute is requested. The overall import time may
    decrease as well for users that don't make use of large portions
    of your library.

    Warning
    -------
    While lazily loading *sub*packages technically works, it causes the
    package (that contains the subpackage) to be eagerly loaded even
    if the package is already lazily loaded.
    So, you probably shouldn't use subpackages with this `load` feature.
    Instead you should encourage the package maintainers to use the
    `lazy_loader.attach` to make their subpackages load lazily.

    Parameters
    ----------
    fullname : str
        The full name of the module or submodule to import.  For example::

          sp = lazy.load('scipy')  # import scipy as sp

    require : str
        A dependency requirement as defined in PEP-508.  For example::

          "numpy >=1.24"

        If defined, the proxy module will raise an error if the installed
        version does not satisfy the requirement.

    error_on_import : bool
        Whether to postpone raising import errors until the module is accessed.
        If set to `True`, import errors are raised as soon as `load` is called.

    Returns
    -------
    pm : importlib.util._LazyModule
        Proxy module.  Can be used like any regularly imported module.
        Actual loading of the module occurs upon first attribute request.

    Nr   zÃsubpackages can technically be lazily loaded, but it causes the package to be eagerly loaded even if it is already lazily loaded.So, you probably shouldn't use subpackages with this lazy feature.zNo module named 'ú'zFound module 'zf' but cannot test requirement '{require}'. Requirements must match distribution name, not module name.z'No distribution can be found matching 'r   é   )r>   r?   r@   rA   r.   )r6   )Ú
threadlockr   r   r(   ÚwarningsÚwarnÚRuntimeWarningr	   ÚutilÚ	find_specÚ_check_requirementrB   Ú
ValueErrorÚinspectÚstackr>   r?   r@   rA   r.   Úmodule_from_specÚ
LazyLoaderÚloaderÚexec_module)ÚfullnamerK   rL   ÚmoduleÚhave_moduleÚmsgÚspecÚnot_found_messageÚerX   Úparentr5   r\   s                r   r   r   }   sá  € ô~ 
ñ >'Ü—‘—‘ Ó*ˆØ DÐ(ˆñ ˜7˜?Ø÷>'ñ >'ð �(‰?ðUð ô
 �M‰M˜#œ~Ô.àˆáÜ—>‘>×+Ñ+¨HÓ5ˆDØ dÐ*ˆKáØ"3°H°:¸QÐ ?ÑØÐ ðÜ0°Ó9�ð #JÈ'ÈÐRSÐ TÐáÙÜ)Ð*;Ó<Ð<ÛðØ Ÿ™›¨Ñ+�à &§¡Ø$Ÿm™mØ &§¡Ø$*×$7Ñ$7ñ	�
ô 0ØØ.Ø-ôð ÷o>'ñ >'ðr ÐÜ—^‘^×4Ñ4°TÓ:ˆFØ$*ŒC�K‰K˜Ñ!ä—^‘^×.Ñ.¨t¯{©{Ó;ˆFØ×Ñ˜vÔ&÷}>'ð@ €MøôK 'ò Ü Ø$ X Jð /Rð Róð ð	ûðûñ8 ú÷o>'ð@ €MúsU   ‡)F+ºAF+ÂFÂF+Â2AF%ÄF+ÄA.F+Æ	F"ÆFÆF"Æ"F+Æ%F(Æ(F+Æ+F5rK   Úreturnc                 óà   — ddl }	 ddlm} |j
                  j                  | «      }|j                  j                  |j                  |j                  «      d¬«      S # t        $ r ddl}Y Œ`w xY w)a�  Verify that a package requirement is satisfied

    If the package is required, a ``ModuleNotFoundError`` is raised
    by ``importlib.metadata``.

    Parameters
    ----------
    require : str
        A dependency requirement as defined in PEP-508

    Returns
    -------
    satisfied : bool
        True if the installed version of the dependency matches
        the specified version, False otherwise.
    r   NT)Úprereleases)Úpackaging.requirementsÚimportlib.metadataÚmetadataÚImportErrorÚimportlib_metadataÚrequirementsÚRequirementÚ	specifierÚcontainsÚversionr   )rK   Ú	packagingrm   Úreqs       r   rV   rV   ÿ   sl   € ó" "ð"Ý7ð ×
 Ñ
 ×
,Ñ
,¨WÓ
5€CØ�=‰=×!Ñ!Ø×"Ñ" 3§8¡8Ó,Øð "ó ð øô	 ò "Ý!ð"ús   †A ÁA-Á,A-c                   ó6   — e Zd ZdZd„ Zdej                  fd„Zy)Ú_StubVisitorzAAST visitor to parse a stub file for submodules and submod_attrs.c                 ó0   — t        «       | _        i | _        y r   )r"   Ú_submodulesÚ_submod_attrs)r4   s    r   r3   z_StubVisitor.__init__!  s   € Ü›5ˆÔØˆÕr   Únodec                 ó¢  — |j                   dk7  rt        d«      ‚|j                  rx| j                  j	                  |j                  g «      }|j
                  D �cg c]  }|j                  ‘Œ }}d|v rt        d|j                  › d�«      ‚|j                  |«       y | j                  j                  d„ |j
                  D «       «       y c c}w )NrO   z;Only within-module imports are supported (`from .* import`)Ú*z4lazy stub loader does not support star import `from z
 import *`c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr   )r   )Ú.0Úaliass     r   ú	<genexpr>z0_StubVisitor.visit_ImportFrom.<locals>.<genexpr>4  s   è ø€ Ò#G°5 E§J¥JÑ#Gùs   ‚)
ÚlevelrW   r_   ry   Ú
setdefaultÚnamesr   Úextendrx   Úupdate)r4   rz   r,   r   Úaliasess        r   Úvisit_ImportFromz_StubVisitor.visit_ImportFrom%  s·   € Ø�:‰:˜Š?ÜØMóð ð �;Š;Ø×,Ñ,×7Ñ7¸¿¹ÀRÓHˆEØ/3¯z©zÖ: e�u—z“zÐ:ˆGÐ:Ø�g‰~Ü ðØ!Ÿ[™[˜M¨ð5óð ð �L‰L˜Õ!à×Ñ×#Ñ#Ñ#G¸D¿J¹JÔ#GÕGùò ;s   ÁCN)rG   rH   rI   Ú__doc__r3   ÚastÚ
ImportFromr‡   r   r   r   rv   rv     s   „ ÙKò ðH S§^¡^ô Hr   rv   r   r>   c                 óÊ  — |j                  d«      r|n$t        j                  j                  |«      d   › d�}t        j                  j	                  |«      st        d|›�«      ‚t        |«      5 }t        j                  |j                  «       «      }ddd«       t        «       }|j                  «       t        | |j                  |j                  «      S # 1 sw Y   ŒExY w)a#  Attach lazily loaded submodules, functions from a type stub.

    This is a variant on ``attach`` that will parse a `.pyi` stub file to
    infer ``submodules`` and ``submod_attrs``. This allows static type checkers
    to find imports, while still providing lazy loading at runtime.

    Parameters
    ----------
    package_name : str
        Typically use ``__name__``.
    filename : str
        Path to `.py` file which has an adjacent `.pyi` file.
        Typically use ``__file__``.

    Returns
    -------
    __getattr__, __dir__, __all__
        The same output as ``attach``.

    Raises
    ------
    ValueError
        If a stub file is not found for `filename`, or if the stubfile is formmated
        incorrectly (e.g. if it contains an relative import from outside of the module)
    Úir   z.pyiz+Cannot load imports from non-existent stub N)Úendswithr&   ÚpathÚsplitextÚexistsrW   Úopenr‰   ÚparseÚreadrv   Úvisitr   rx   ry   )r   r>   ÚstubfileÚfÚ	stub_nodeÚvisitors         r   r   r   7  s¿   € ð6 ×%Ñ% cÔ*‰´2·7±7×3CÑ3CÀHÓ3MÈaÑ3PÐ2QÐQUÐ0Vð ô �7‰7�>‰>˜(Ô#ÜÐFÀxÀlÐSÓTÐTä	ˆh‹ð (˜1Ü—I‘I˜aŸf™f›hÓ'ˆ	÷(ô ‹n€GØ‡M�M�)ÔÜ�, × 3Ñ 3°W×5JÑ5JÓKÐK÷(ð (ús   Á1$CÃC")NN)rˆ   r‰   r	   Úimportlib.utilr&   r   Ú	threadingÚtypesrQ   Ú__version__r   ÚLockrP   r   Ú
ModuleTyper.   r   ÚstrÚboolrV   ÚNodeVisitorrv   r   r   r   r   ú<module>r¢      s    ðñó Û Û Û 	Û 
Û Û Û à€Ú
+€ð ˆY�^‰^Ó€
óO/ôd˜u×/Ñ/ô ð& #°Eô ðD ð ¨ó ô>H�3—?‘?ô Hð2&L˜cð &L¨Sô &Lr   