
    恕f#                     d    d dl Z d dlZddlmZmZ dZdZddZd ZddZ	dd	Z
dd
Zd Zd Zd Zy)    N   )reduce
as_unicode.,c                     	 t        | t               t               g        t
        j                  |    S # t        $ r |st	               rY y w xY w)a"  
        Import module by name

        :param name:
            Module name
        :param required:
            If set to `True` and module was not found - will throw exception.
            If set to `False` and module was not found - will return None.
            Default is `True`.
    N)
__import__globalslocalsImportErrormodule_not_foundsysmodules)namerequireds     P/var/www/feuerwehr-webapp/venv/lib/python3.12/site-packages/flask_admin/tools.pyimport_moduler      sJ    4FHb1
 ;;t	  ,.s   3 A
Ac                     | j                  dd      \  }}t        |t               t               |g      }t	        ||      S )z
        Import attribute using string reference.

        :param name:
            String reference.

        Raises ImportError or AttributeError if module or attribute do not exist.

        Example::

            import_attribute('a.b.c.foo')

    r   r   )rsplitr	   r
   r   getattr)r   pathattrmodules       r   import_attributer      s;     S!$JD$giD6:F64      c                 |    t        j                         d   }t        t        j                  |            d| z   kD  ryy)a  
        Checks if ImportError was raised because module does not exist or
        something inside it raised ImportError

        :param additional_depth:
            supply int of depth of your call if you're not doing
            import on the same level of code - f.e., if you call function, which is
            doing import, you should pass 1 for single additional level of depth
       r   FT)r   exc_infolen	traceback
extract_tb)additional_depthtbs     r   r   r   3   s8     
	B
9#$,<(<=r   c                 f    	 t        t        |j                  d      |       S # t        $ r |cY S w xY w)z
        Recursive getattr.

        :param attr:
            Dot delimited attribute name
        :param default:
            Default value

        Example::

            rec_getattr(obj, 'a.b.c')
    r   )r   r   splitAttributeErrorobjr   defaults      r   rec_getattrr*   C   s2    gtzz#44 s   " 00c                     | g| j                   j                         z   D ]!  } || j                  v s| j                  |   c S  |S )z
        Get attribute of the object without triggering its __getattr__.

        :param obj:
            Object
        :param attr:
            Attribute name
        :param default:
            Default value if attribute was not found
    )	__class__mro__dict__r'   s      r   get_dict_attrr/   V   sI     us}}((** &3<<<<%%& Nr   c                     t        |       j                  t        t        t        z         j                  t        t        t        z         S Nr   replaceCHAR_ESCAPECHAR_SEPARATOR)values    r   escaper7   h   s2    uW[+";<W^[>%ABDr   c                 2    dj                  d | D              S )zn
        Encode enumerable as compact string representation.

        :param iter:
            Enumerable
    r   c              3      K   | ]M  }t        |      j                  t        t        t        z         j                  t        t        t        z          O y wr1   r2   ).0vs     r   	<genexpr>ziterencode.<locals>.<genexpr>u   sF      #  qMW[+*CDW^[>-IJK #s   AA)join)iters    r   
iterencoder?   n   s$     88 # "# # #r   c                     | s
t               S g }d}d}| D ]4  }|s)|t        k(  rd}|t        k(  r|j                  |       d}.d}||z  }6 |j                  |       t        |      S )zC
        Decode enumerable from string presentation as a tuple
     FT)tupler4   r5   append)r6   resultaccumulatorescapedcs        r   
iterdecoderH   {   s    
 wFKG Kn$k*!Gq MM+=r   )T)r   r1   )r   r    _compatr   r   r4   r5   r   r   r   r*   r/   r7   r?   rH    r   r   <module>rK      sC    
  ((!( &$D
#r   