K iH HddlmZddlZddlZddlmZdddZd d dZd dZy) ) annotationsN)SequencecJt|tr|j|dS|S)Nreplace) isinstancebytesdecode)sencodings ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/traitlets/utils/__init__.py cast_unicoder s"!Uxx),, Hct|jdjd}tjj|r!tjj |r|S|d}n:t |t r|f}n&t |tjr t |f}|D]}|dk(rtj}ttjj||}tjj |setjj|cStd|d|)aFind a file by looking through a sequence of paths. This iterates through a sequence of paths looking for a file and returns the full, absolute path of the first occurrence of the file. If no set of path dirs is given, the filename is tested as is, after running through :func:`expandvars` and :func:`expanduser`. Thus a simple call:: filefind('myfile.txt') will find the file in the current working dir, but:: filefind('~/myfile.txt') Will find the file in the users home directory. This function does not automatically try any paths, such as the cwd or the user's home directory. Parameters ---------- filename : str The filename to look for. path_dirs : str, None or sequence of str The sequence of paths to look for the file in. If None, the filename need to be absolute or be in the cwd. If a string, the string is put into a sequence and the searched. If a sequence, walk through each element and join with ``filename``, calling :func:`expandvars` and :func:`expanduser` before testing for existence. Returns ------- Raises :exc:`IOError` or returns absolute path to file. "').zFile z, does not exist in any of the search paths: )stripospathisabsisfilerstrpathlibPathgetcwd expand_pathjoinabspathOSError)filename path_dirsrtestnames r filefindr$sD~~c"((-H ww}}X277>>(#; Is #L Iw|| ,^% - 3;99;Drww||D(;< 77>>( #77??8, , - E(%QR[Q^_ ``rctjdk(r|jdd}tjj tjj |}tjdk(r|jdd}|S)zExpand $VARS and ~names in a string, like a shell :Examples: In [2]: os.environ['FOO']='test' In [3]: expand_path('variable FOO is $FOO') Out[3]: 'variable FOO is test' ntz$\ IPYTHON_TEMP)rnamerr expandvars expanduser)r s r rrGsb ww$ IIe^ , 277--a01A ww$ IIne , Hr)zutf-8)r z str | bytesr rreturnr)N)r!rr"zSequence[str] | Noner+r)r rr+r) __future__rrrtypingrr r$rrr r/s""  5ap r