TL ifC0dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZmZmZddlZe rddlmZed d Zgd Zd d gZdZej2j4dej2j6ZGddeZGddZdZ GddeZ!GddZ"Gdde"e!Z#Gdde"eZ$d3dZ%dZ&dZ'd Z(d!Z)e d"#d$Z*d4d%d%d&d'Z+dd(d)Z,dd(d*Z-d%dd+d,Z.d5d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4y)6z Environments are a way to activate different Python versions or Virtualenvs for static analysis. The Python binary in that environment is going to be executed. N) namedtuple)which) TYPE_CHECKING)memoize_method time_cache)CompiledSubprocessInferenceStateSameProcessInferenceStateSubprocess)InferenceState VersionInfozmajor minor micro)z3.13z3.12z3.11z3.10z3.9z3.8z3.7z3.6z/usr/binz/usr/local/bin CONDA_PREFIX.ceZdZdZy)InvalidPythonEnvironmentz If you see this exception, the Python executable or Virtualenv you have been trying to use is probably not a correct Python version. N)__name__ __module__ __qualname____doc__Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/api/environment.pyrrsrrc,eZdZedZedZy)_BaseEnvironmentc|jjd|jj}tj|S)Nrversion) version_infomajorminorparso load_grammar)selfversion_strings r get_grammarz_BaseEnvironment.get_grammar's5$($5$5$;$;T=N=N=T=TU!!.99rc |jS#t$r)t|j|_|jcYSwxYwN)_hashAttributeError_calculate_sha256_for_file executabler"s r_sha256z_BaseEnvironment._sha256,s: ::  3DOODDJ::  s /AAN)rrrrr$propertyr,rrrrr&s(::rrcftjtjtjddfSN)sysr*prefixrrrr _get_infor35s*   ! rcHeZdZdZdZd dZdZdZdddefd Z e d Z y) Environmentz This class is supposed to be created by internal Jedi architecture. You should not create it directly. Please use create_environment or the other functions instead. It is then returned by that function. Nc@||_||_|jyr&)_start_executable _env_vars_get_subprocess)r"r*env_varss r__init__zEnvironment.__init__Es!+! rc|j"|jjs |jS t|j|j|_|jj dt }|d|_ |d|_ t|d|_ |jS#t$r }td|jd|d}~wwxYw)Nr:z&Could not get version information for : r) _subprocess is_crashedrr7r8_sendr3 Exceptionrr*path _VersionInfor)r"infoexcs rr9zEnvironment._get_subprocessKs    '0@0@0K0K## # 1$2H2H;?>> KD ##))$ :Dq' G  )$q'2 + ***  sAB)) C2C  Ccdjd|jD}d|jjd|d|jdS)Nrc32K|]}t|ywr&)str).0is r z'Environment.__repr__..ks=a3q6=sz in >)joinr __class__rrE)r"rs r__repr__zEnvironment.__repr__js7((=4+<+<==#'>>#:#:GTYYOOrinference_stater returnc6t||jSr&)r r9r"rTs rget_inference_state_subprocessz*Environment.get_inference_state_subprocessns(9M9M9OPPrc>|jjS)z The sys path for this environment. Does not include potential modifications from e.g. appending to :data:`sys.path`. :returns: list of str )r9 get_sys_pathr+s rrZzEnvironment.get_sys_pathts##%2244rr&) rrrrrAr;r9rSr rXrrZrrrr5r5=sL K  >PQ)Q "Q  5 5rr5ceZdZdZy)_SameEnvironmentMixinctjx|_|_tj|_t tj dd|_d|_yr/)r1r*r7r2rErFrr8r+s rr;z_SameEnvironmentMixin.__init__sA36>>AJJ (#*:*:2A*>?rN)rrrr;rrrr\r\srr\c eZdZy)SameEnvironmentN)rrrrrrr_r_srr_c"eZdZdddefdZdZy)InterpreterEnvironmentrTr rUct|Sr&)r rWs rrXz5InterpreterEnvironment.get_inference_state_subprocesss)99rc"tjSr&)r1rEr+s rrZz#InterpreterEnvironment.get_sys_paths xxrN)rrrr rXrZrrrraras:): #: rrac.tjj|}|retjj |tjj t j k(r tS t|dSy#t$rYywxYw)zGet virtualenv environment from VIRTUAL_ENV environment variable. It uses `safe=False` with ``create_environment``, because the environment variable is considered to be safe / controlled by the user solely. FsafeN) osenvirongetrErealpathr1r2_try_get_same_envcreate_environmentr)env_varvars r_get_virtual_env_from_varrosy **.. !C 77  C BGG$4$4SZZ$@ @$& & %c6 6 (   s: B BBctj}t|d5tfddD]}|j | ddd|j S#1swY|j SxYw)NrbcBjtjSr&)readfilecmpBUFSIZE)fsrz,_calculate_sha256_for_file..s!&&"9rr)hashlibsha256openiterupdate hexdigest)rEryblockrvs @rr)r)sp ^^ F dD !Q93? !E MM%  !!    !    s &A!!A9cXt}||Stt}||StS)a| Tries to return an active Virtualenv or conda environment. If there is no VIRTUAL_ENV variable or no CONDA_PREFIX variable set set it will return the latest Python version installed on the system. This makes it possible to use as many new Python features as possible when using autocompletion and other functionality. :returns: :class:`.Environment` )ro _CONDA_VARrk) virtual_env conda_envs rget_default_environmentrs7,-K)*5I  rc*t}tjj|jj j dstjdk(rd}nAdtjddtjddtjdzdf}|D]\}tjjtj|}tjj|sQt|cStS|S) Npythonnt)zScripts\python.exe python.exez bin/pythonrrr?z bin/python%s)r_rgrEbasenamer*lower startswithnamer1rrrQ exec_prefixisfiler5ra)envcheckscheckguesss rrkrks  C 77  CNN + 1 1 3 > >x H 77d?;F &)%5%5a%8#++a.I#"2"21"56F  *EGGLL%8Eww~~e$"5))  * &'' Jrcttjjdxs#tjjt}t }|rgtj j |tj j |j k7rtjt S|S)N VIRTUAL_ENV)rgrhrir_get_cached_default_environmentrErj clear_cache)rn environments rget_cached_default_environmentrsy **.. ' E2::>>*+EC13K  rww$(8(89I9I(JJ'335.00 riX)secondscJ tS#t$r tcYSwxYwr&)rrrarrrrrs*(&(( #( &'' (s ""T)rfuse_environment_varsc#bK|g}t}|r[t}|||j|jtt}|||j|j|D]}t jj |s#t jj|}t j|D]S}t jj||}||vr(|j| t||}t|Uy#t$rYdwxYww)a  :param paths: A list of paths in your file system to be scanned for Virtualenvs. It will search in these paths and potentially execute the Python binaries. :param safe: Default True. In case this is False, it will allow this function to execute potential `python` environments. An attacker might be able to drop an executable in a path this function is searching by default. If the executable has not been installed by root, it will not be executed. :param use_environment_vars: Default True. If True, the VIRTUAL_ENV variable will be checked if it contains a valid VirtualEnv. CONDA_PREFIX will be checked to see if it contains a valid conda environment. :yields: :class:`.Environment` Nre) setroaddrErrgisdirabspathlistdirrQ_get_executable_pathr5r) pathsrfr _used_pathsrr directoryrEr*s rfind_virtualenvsrs" }%K01  "  OOK,, --j9  O OOINN + ww}}Y' GGOOI. JJy) D77<< 40D{" OOD ! 1$TB !*--  ,  s*C>D/D D/ D,)D/+D,,D/r=c#`KtD]} t||y#t$rY!wxYww)a& Ignores virtualenvs and returns the Python versions that were installed on your system. This might return nothing, if you're running Python e.g. from a portable version. The environments are sorted from latest to oldest Python version. :yields: :class:`.Environment` r=N)_SUPPORTED_PYTHONSget_system_environmentr)r:r#s rfind_system_environmentsrEs<- ((K K(   s .. +.+.ctd|z}|r(|tjk(r tSt |St j dk(rt|D]} t ||cStd|z#t$rY-wxYw)z Return the first Python environment found for a string of the form 'X.Y' where X and Y are the major and minor versions of Python. :raises: :exc:`.InvalidPythonEnvironment` :returns: :class:`.Environment` rrr=z Cannot find executable python%s.) rr1r*r_r5rgr&_get_executables_from_windows_registryr)rr:exes rrrXs 7" #C #.. "$ $3 ww$9'B C "3::  ##E#O PP,  s A99 BB)rfr:ctjj|rt||t ||St t |||S)z Make it possible to manually create an Environment object by specifying a Virtualenv path or an executable path and optional environment variables. :raises: :exc:`.InvalidPythonEnvironment` :returns: :class:`.Environment` r=re)rgrEr _assert_safer5r)rErfr:s rrlrlos@ ww~~dT4 4(33 +Dt TS_@`a77<<eX67K 77>>& ! K''@6'IJJ Mrc#Kddl}gd}|j|jfD]}|D]}|j|} |j ||5}|j |dd}t jj|d}t jj|r|dddy#1swYxYw#t$rYwxYww)Nr)z0SOFTWARE\Python\PythonCore\{version}\InstallPathz.s@q9''*@sr)_is_unix_adminany _SAFE_PATHSrgstatst_uid)ruids` rrrs;@K@@@ '')  # #C !8OrcP tjdk(S#t$rYywxYw)NrF)rggetuidr(rrrrrs*yy{a s  %%)rr&)T)5rrgr1rxrt collectionsrshutilrtypingr jedi.cacherr"jedi.inference.compiled.subprocessrr r r jedi.inferencer rFrrrrrr_CURRENT_VERSIONrDrrr3r5r\r_raror)rrkrrrrrrlrrrrrrrrrrsW " 188 --)<= Q+,  !..44c6F6F6L6LMy  D5"D5N +[ 24D**%P  G((3D3l*.&15Q.&*D Q&.8 8&r