Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/utils/__pycache__/path.cpython-39.pyc
Ðазад
a o�h�. � @ s d Z ddlZddlZddlZddlZddlZddlZddlmZ e� � Z dd� Zejdkrddd� Z nd d� Z d d� Zdd � Zdd� Zd/eed�dd�ZG dd� de�Zd0ed�dd�Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'Zd(d)� Zd*d+� Zd1d-d.�Z dS )2z Utilities for path handling. � N)�systemc C s t j�| �ot �| t j�S )zBWhether `path` is a directory, to which the user has write access.)�os�path�isdir�access�W_OK�r � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/utils/path.py� _writable_dir s r �win32c C s� zddl }W n. ty: } ztd�|�W Y d}~n d}~0 0 |jjj}|j|j|jg|_|�d�}|| |d�}|dks~|dkr�| S |j S dS )z�Get a long path name (expand ~) on Windows using ctypes. Examples -------- >>> get_long_path_name('c:\\docume~1') 'c:\\Documents and Settings' r Nz2you need to have ctypes installed for this to worki ) �ctypes�ImportErrorZwindllZkernel32ZGetLongPathNameWZ c_wchar_pZc_uint�argtypesZcreate_unicode_buffer�value)r r �eZ_GetLongPathName�buf�rvr r r �_get_long_path_name s � r c C s | S )zDummy no-op.r r r r r r 5 s c C s t | �S )z�Expand a path into its long form. On Windows this expands any ~ in the paths. On other platforms, it is a null operation. )r r r r r �get_long_path_name; s r c C s. t j�d�}| �|�r*d| t|�d� } | S )z*Reverse of :func:`os.path.expanduser` �~N)r r � expanduser� startswith�len)r �homer r r � compress_userD s r c C sN t j�| �} t j�| �r| S | �d�s>| d }t j�|�r>|S td| ��dS )z�Return a valid python filename in the current directory. If the given name is not a file, it adds '.py' and searches again. Raises IOError with an informative message if the file isn't found. z.pyzFile `%r` not found.N)r r r �isfile�endswith�IOError)�nameZpy_namer r r �get_py_filenameL s r )�filename�returnc C s� | � d�� d�} tj�| �r,tj�| �r,| S |du r:d}nt|t�rJ|f}|D ]B}|dkrbt�� }ttj� || ��}tj�|�rNtj� |� S qNtd| |f ��dS )a� Find 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 ------- path : str returns absolute path to file. Raises ------ IOError �"�'N)� �.z5File %r does not exist in any of the search paths: %r)�stripr r �isabsr � isinstance�str�getcwd�expand_path�join�abspathr )r! � path_dirsr Ztestnamer r r �filefind] s ' �r0 c @ s e Zd ZdS )�HomeDirErrorN)�__name__� __module__�__qualname__r r r r r1 � s r1 F)r"