o
    b                     @   s   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mZmZm	Z	 ddl
mZ i ZdZdd Zdd	 Zd
d Zdd Zee ee	jee dS )zAstroid hooks for the Python 2 GObject introspection bindings.

Helps with understanding everything imported from 'gi.repository'
    N)MANAGERAstroidBuildingErrornodes)AstroidBuilderz^[A-Za-z_]\w*$c                 C   s  i }i }i }i }t | D ]|}|drqtt|sqzt| |}W n   Y qt|r2|||< qt|s<t	|rA|||< qt
|sKt|rP|||< qt|dsjt|dsjt|dsjt|rod||< qt|ttfr{|||< qt|r|||< qd||< qd}|r|d| j 7 }t|D ](}|d  rq|| }t|}	t|trdt|d	d
 }	|d||	f 7 }q|r|d7 }|r|d| j 7 }t|D ]}|d| 7 }|d7 }q|r|d7 }|r|d| j 7 }t|D ]}|d| 7 }|d7 }q|r|d7 }|r|d| j 7 }t| D ]4\}}d}
t|tr&d}
|d||
f 7 }t|}|s7d}| D ]}|d| d 7 }q;|d7 }q|S )z`
    Inspect the passed module recursively and build stubs for functions,
    classes, etc.
    __z<flagsz<enum z<GType r    z# %s constants

z"%s"\z\\z%s = %s
z

z# %s functions

zdef %s(*args, **kwargs):
z	    pass
z# %s methods

zdef %s(self, *args, **kwargs):
z# %s classes

object	Exceptionzclass %s(%s):
zpass
z    
)dir
startswithrematch_identifier_regetattrinspectisclass
isfunction	isbuiltinismethodismethoddescriptorstrisdatadescriptor
isinstanceintcallable__name__sortedisdigitreplaceitems
issubclassr
   _gi_build_stub
splitlines)parentclassesZ	functions	constantsmethodsnameobjretvalstrvalbaseZclassretline r0   U/var/www/secure340b-portal/env/lib/python3.10/site-packages/astroid/brain/brain_gi.pyr#   !   s   











r#   c              
   C   s`  |  ds
t| d| tvr| g}g }| dkr|d n	| dkr&|d z^d}t||D ]S}zCt 5 zdd	lm	}m
} td
| td
| W n	 tyV   Y nw t| |ttj| 7 }W d    n1 snw   Y  W q/ ty   ||vr Y q/w W n ty   d  }t| < Y nw tt|| }|t| < nt|  }|d u rt| d|S )Nzgi.repository.)modnamezgi.repository.GLibzgi._glibzgi.repository.GObjectzgi._gobjectr   r   )PyGIDeprecationWarningPyGIWarningignore)r   r   _inspected_modulesappend	itertoolschainwarningscatch_warningsgir3   r4   simplefilterr
   
__import__r#   sysmodulesImportErrorr   r   Zstring_build)r2   modnamesZoptional_modnamesZmodcodemr3   r4   Zastngr0   r0   r1   _import_gi_module   sP   





rD   c                 C   s   t | jdkr	dS tdd | jD sdS | j}t|tjr6|jdkr%dS t|jtj	r4|jj
dkr4dS dS t|tj	rA|j
dkS dS )N   Fc                 s   s    | ]	}t |tjV  qd S )N)r   r   ZConst).0argr0   r0   r1   	<genexpr>   s    z._looks_like_require_version.<locals>.<genexpr>require_versionr<   T)lenargsallfuncr   r   	AttributeattrnameexprNamer)   )noderM   r0   r0   r1   _looks_like_require_version   s   

rS   c                 C   s@   zdd l }|| jd j| jd j W | S  ty   Y | S w )Nr      )r<   rI   rK   valuer
   )rR   r<   r0   r0   r1   _register_require_version   s   rV   )__doc__r   r8   r?   r   r:   Zastroidr   r   r   Zastroid.builderr   r6   r   r#   rD   rS   rV   Zregister_failed_import_hookZregister_transformCallr0   r0   r0   r1   <module>   s$   b2
