bg(F,dZddlmZddlZddlZddlZddlZddlmZm Z m Z ddl m Z m Z ddlmZmZddlmZddlmZdd lmZdd lmZmZdd lmZmZdd lmZmZdd l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+ddl,m-Z-m.Z.dZ/ddZ0GddZ1dS)zastroid manager: avoid multiple astroid build of a same module when possible by providing a class responsible to get astroid representation from various source and using a cache of built modules) ) annotationsN)CallableIteratorSequence) find_specmodule_from_spec)AnyClassVar)nodes) CACHE_MANAGER)BRAIN_MODULES_DIRECTORY)InferenceContext_invalidate_cache)AstroidBuildingErrorAstroidImportError)specutil) NoSourceFile_cache_normalize_path_file_info_from_modpathget_source_file2is_module_name_part_of_extension_package_whitelistis_python_sourceis_stdlib_moduleload_module_from_namemodpath_from_file)TransformVisitor)AstroidManagerBrainInferenceResult)z.zipz.eggz.whlz.pyzz.pyzwobjr returnstrcD t|S#t$rYdSwxYw)Nz???)repr Exception)r s `/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/manager.py safe_reprr'+s5Cyy uus  ceZdZUdZdZiigddeedZded<dZ ded <dGd Z e dHdZ e j dIdZ e dHdZej dIdZe dZe dZe dJdZdKdZ dLdMd#Z dNdOd&ZdPd'ZdQd*ZdRd+Z dSdTd.ZdUd0ZdVd3Z dWdXd6ZdWdYd:Z dWdZd@Zd[dCZd\dDZdGdEZ dGdFZ!dS)]AstroidManagerz_Responsible to build astroid from files or modules. Use the Borg (singleton) pattern. zastroid loaderF) astroid_cache_mod_file_cache_failed_import_hooksalways_load_extensions optimize_astextension_package_whitelist _transformrbraindz ClassVar[int]max_inferable_valuesr!Nonectjd|_tjd|_tjd|_tjd|_tjd|_dS)Nr*r+r,r/r0)r)r1r*r+r,r/r0selfs r&__init__zAstroidManager.__init__Ds\+1/B-34EF$2$89O$P!+9+? ), ().|<boolc&tjdSNr-r)r1r6s r&r-z%AstroidManager.always_load_extensionsNs#$<==r9valuec$|tjd<dSr<r=r7r>s r&r-z%AstroidManager.always_load_extensionsRs9>5666r9c&tjdSNr.r=r6s r&r.zAstroidManager.optimize_astVs#N33r9c$|tjd<dSrBr=r@s r&r.zAstroidManager.optimize_astZs/4^,,,r9c|jjSN)r0register_transformr6s r&rFz!AstroidManager.register_transform^s11r9c|jjSrE)r0unregister_transformr6s r&rHz#AstroidManager.unregister_transformcs 33r9 nodes.Modulec|jdS)Nbuiltins)r*r6s r&builtins_modulezAstroidManager.builtins_modulegs!*--r9node nodes.NodeNGrc6|j|S)z8Visit the transforms and apply them to the given *node*.)r0visit)r7rMs r&visit_transformszAstroidManager.visit_transformsks$$T***r9NTfilepathr"modname str | Nonefallbacksourcec t|d}d}n#t$rYnwxYw|6 dt|}n#t$r|}YnwxYw||jvr#|j|j|kr |j|S|r%ddlm}|| ||S|r|r| |Std|) /Given a module name, return the astroid object.T)include_no_extN.rAstroidBuilderz"Unable to build an AST for {path}.)path) rrjoinr ImportErrorr*fileastroid.builderr\ file_buildast_from_module_namer)r7rRrSrUrVr\s r& ast_from_filezAstroidManager.ast_from_fileos0 &xEEEHFF    D  ? #((#4X#>#>?? # # #" # t) ) )"7+0H<<%g. .  F 6 6 6 6 6 6!>$''228WEE E  6 6,,W55 5"#GhWWWWs ##"A AAdatacNddlm}|||||S)z]Given some source code as a string, return its corresponding astroid object. rr[rar\ string_build)r7rfrSrRr\s r&ast_from_stringzAstroidManager.ast_from_strings8 322222~d##00wIIIr9cLddlm}||d|S)Nrr[rerh)r7rSr\s r&_build_stub_modulez!AstroidManager._build_stub_modules4222222~d##00W===r9r] Sequence[str]c&ddlm}|||S)Nr)build_namespace_package_module)raro)r7rSr]ros r&_build_namespace_modulez&AstroidManager._build_namespace_modules* CBBBBB--gt<<?? ? d( ( (Y (%g. . j **733 3  4ikkG HRW__\22 3 3 3; "33G\JJJ$/">>>--j.ABB%!j "!!!! "m&)+% Ot'BBB 44W==C 227;;V "!!!! "U#8#A#ALL ,A ''0  ++L'BBD "!!!! "ADO$???(?##, DO$@@@33ZBHb0 "!!!! "+DO$===&.227;;& "!!!! "!))**=wQV)WW  "!!!! ""*(=w%%j&97U%SS "!!!! "$   1  4==(((((((  "!!!! " ,DG   "!!!! "s A L+1A.L+8FL+ F/F**F//L+A'L+5L++L+4L++ M?5 M:? M( M: M? N( M52M:4M55M::M??NNnodes.Module | NonectdSddlm}||}tD]} ||t jjzd\}}n#t$rY;wxYw tj ||z}| t jjd}| |r|dz}| | |||} | cS#t$rYwxYwdS)Nrr[rZz .__init__) zipimportrar\ZIP_IMPORT_EXTSrsplitrxr]sep ValueError zipimporterreplace is_packageri get_sourcer%) r7rRr\builderexteggpathresourceimporterzmodnamers r&rzAstroidManager.zip_import_datas3  4 322222 .&&"  C $,OOC"'+4Eq$I$I!     $03??#++BGK==&&x006'+5H --''118X     ts$+A AA"BC&& C32C3 contextfilespec.ModuleSpecc x |j||f}n~#t$rq t|d|}n<#t$r/}t d||d}Yd}~nd}~wwxYw||j||f<YnwxYwt|tr|d|S)NrZ)rtz6Failed to import module {modname} with error: {error}.)rSerror) r+KeyErrorrsplitr_rwith_traceback isinstancer)r7rSrr>rs r&r|z$AstroidManager.file_from_module_names A(';)?@EE A A A .MM#&&[   *M#**400  >   &GG   &8$U++      $$U++      >DD   &8$U++      $S$U++   ..w77 C<<&//g>>    '//g>> 3 300222222 3 3sH(A00 C : B C ' CC C D4" D D4 D//D4rCallable[[str], nodes.Module]c:|j|dS)a}Registers a hook to resolve imports that cannot be found otherwise. `hook` must be a function that accepts a single argument `modname` which contains the name of the module or package that could not be imported. If `hook` can resolve the import, must return a node of type `astroid.Module`, otherwise, it must raise `AstroidBuildingError`. N)r,append)r7rs r&register_failed_import_hookz*AstroidManager.register_failed_import_hooks! !((.....r9cF|j|j|dS)z >F}%%'(F(F(FGG """{ 0 = = "))))"..}===  > >r9)r!r4)r!r:)r>r:r!r4)r!rI)rMrNr!r)NTF) rRr"rSrTrUr:rVr:r!rI)reN)rfr"rSr"rRrTr!rI)rSr"r!rI)rSr"r]rmr!rI)rSr"r!r:rr)rSrTrtrTrur:r!rI)rRr"r!r)rSr"rrTr!rrE)rrrSrTr!rI)rr}rSrTr!r)r rrrr!r)rrr!r4)rrIr!r4)"rr __qualname____doc__rsetrr1__annotations__r3r8propertyr-setterr.rFrHrLrQrdrjrlrprsrcrr|rrrrrrrr9r&r)r)2s  D ""''*suu&&((""E+.----====>>>X>"???#"?444X4555522X244X4...X.++++# XXXXXBDH J J J J J>>>> ====    $( O"O"O"O"O"b62?CBBBBB*$?C2323232323h////;;;;....&>&>&>&>&>&>r9r))r r r!r")2r __future__rrrxtypesrcollections.abcrrrimportlib.utilrrtypingr r rr astroid._cacher astroid.constr astroid.contextrrastroid.exceptionsrrastroid.interpreter._importrrastroid.modutilsrrrrrrrrrastroid.transformsrastroid.typingrrrr'r)rr9r&rs  #""""" 888888888866666666 ((((((111111????????GGGGGGGG22222222                      0/////????????;[>[>[>[>[>[>[>[>[>[>r9