
    Ki                         d dl mZ daed        Zd Zd Zd dlZej                  dk  r2 e         e	       j                  d t        j                  D               [	 d dlmZ y# e$ r Y yw xY w)	    )contextmanagerNc               #   ,  K   	 ddl m} m} | |z  }ddl} |j                         }	  |j                  |       d  |j                  |       y# t        $ r! 	 ddlm} m} n# t        $ r d Y Y yw xY wY mw xY w#  |j                  |       w xY ww)at  
    A context manager for enabling binary Lua module loading when importing Lua.

    This can only be used once within a Python runtime and must wrap the import of the
    ``lupa.*`` Lua module, e.g.::

        import lupa
        with lupa.allow_lua_module_loading()
            from lupa import lua54

        lua = lua54.LuaRuntime()
        lua.require('cjson')
    r   )RTLD_NOWRTLD_GLOBALN)osr   r   ImportErrorDLFCNsysgetdlopenflagssetdlopenflags)r   r   dlopen_flagsr
   	old_flagss        Y/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/lupa/__init__.pyallow_lua_module_loadingr      s     , k)L"""$I&<(9%#  	33 		 4" 	9%sg   BA BA= B	A:A#"A:#A40A:1B3A44A:7B9A::B=BBc                  X   t         t         S dd l} dd l| j                  j	                  t
              }fd| j                  |      D        D cg c]  }|r|j                          }}|st        d      t        |d       }t        |d   ddt                     a t         S c c}w )	Nr   c              3   B   K   | ]  }j                  d |        yw)z((lua[a-z]*)([0-9]*))\..*N)match).0filenameres     r   	<genexpr>z%_import_newest_lib.<locals>.<genexpr>6   s%      %
 HH18<%
s   z$Failed to import Lupa binary module.c                 R    | d   dk(  t        t        t        | d   xs d            fS )N   lua   0)tuplemapint)ms    r   <lambda>z$_import_newest_lib.<locals>.<lambda>?   s(    ademU3sAaDKTWCX=Y-Z     )keyr   *)levelfromlistglobals)_newest_libos.pathr   pathdirname__file__listdirgroupsRuntimeErrormax
__import__r'   )r   package_dirr   modulesmodule_namer   s        @r   _import_newest_libr5   ,   s    ''//(+K%
JJ{3%
  	 	G  ABBg#Z[K[^1sGIVKs   B'c                 ^   | j                  d      rTddl}|j                  d|       r>| t               vsJ 	 t	        | t               t               d      }| t               v sJ |S t        t        n	t               }t        ||       xt               | <   }|S # t        $ r t        |       w xY w)zh
    Get a name from the latest available Lua (or LuaJIT) module.
    Imports the module as needed.
    r   r   Nz((lua[a-z]*)([0-9]*))$r   )r'   localsr%   )
startswithr   r   r'   r1   r7   r   AttributeErrorr(   r5   getattr)namer   moduler   attrs        r   __getattr__r>   E   s    
 u88-t4wy(((#D')FHTUV wy((( %0+6H6JC$S$//GIdOdK  +$T**+s   B B,)      c              #   @   K   | ]  }|t        t        |      f  y w)N)r:   r(   )r   r;   s     r   r   r   a   s$       
w{D)*s   )__version__)
contextlibr   _contextmanagerr(   r   r5   r>   r
   version_infor'   update__all__lupa.versionrB   r    r"   r   <module>rJ      s    8  !& !&H20 fI ''  	( 		s   A% %A-,A-