%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/filepath.cpython-312.pyc |
� Ϫ�f�� � �& � d Z ddlmZ ddlZddlZddlZddlZddlmZmZm Z ddl mZmZm Z mZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7 dd l#m8Z8 dd l9m:Z:m;Z; ddl<m=Z= ddl>m?Z? dd l@mAZAmBZBmCZCmDZDmEZE ej� ej� z ej� z eEz ZI e0dd�� ZJej� ZLej� ZN G d� de6� ZO G d� deP� ZQ G d� deP� ZR G d� deS� ZTd'd�ZU e0deVeW� ZXe8d ZY G d� de*e' � ZZ G d� de?� Z[ G d � d!e?� Z\d(d)d"�Z]d*d+d#�Z^ d* d,d$�Z_e; e7eO� G d%� d&eZe' � � � Z`y)-z1 Object-oriented filesystem path representation. � )�annotationsN)�listdir�stat�utime) �abspath�basename�dirname�exists�isabs�islink�join�normpath�splitext)�S_IMODE�S_IRGRP�S_IROTH�S_IRUSR�S_ISBLK�S_ISDIR�S_ISREG�S_ISSOCK�S_IWGRP�S_IWOTH�S_IWUSR�S_IXGRP�S_IXOTH�S_IXUSR)�IO� TYPE_CHECKING�Any�AnyStr�Callable�Dict�Generic�Iterable�List�Optional�Sequence�Tuple�TypeVar�Union�cast�overload)� Attribute� Interface�implementer)�Literal)�cmp� comparable)�platform)�FancyEqMixin)�ERROR_DIRECTORY�ERROR_FILE_NOT_FOUND�ERROR_INVALID_NAME�ERROR_PATH_NOT_FOUND�O_BINARY�_SelfzAbstractFilePath[Any]��boundc � � e Zd ZdZ ed� Zdd�Zddd�Zdd�Zdd�Z dd�Z dd�Zdd �Zdd �Z dd�Zdd�Zdd �Zdd�Zdd�Zdd�Zy)� IFilePatha� File path object. A file path represents a location for a file-like-object and can be organized into a hierarchy; a file path can can children which are themselves file paths. A file path has a name which unique identifies it in the context of its parent (if it has one); a file path can not have two children with the same name. This name is referred to as the file path's "base name". A series of such names can be used to locate nested children of a file path; such a series is referred to as the child's "path", relative to the parent. In this case, each name in the path is referred to as a "path segment"; the child's base name is the segment in the path. When representing a file path as a string, a "path separator" is used to delimit the path segments within the string. For a file system path, that would be C{os.sep}. Note that the values of child names may be restricted. For example, a file system path will not allow the use of the path separator in a name, and certain names (e.g. C{"."} and C{".."}) may be reserved or have special meanings. @since: 12.1 z3The path separator to use in string representationsc � � y)a� Obtain a direct child of this file path. The child may or may not exist. @param name: the name of a child of this path. C{name} must be a direct child of this path and may not contain a path separator. @return: the child of this path with the given C{name}. @raise InsecurePath: if C{name} describes a file path that is not a direct child of this file path. N� ��names �9/usr/lib/python3/dist-packages/twisted/python/filepath.py�childzIFilePath.childy � � � c � � y)z� Opens this file path with the given mode. @return: a file-like object. @raise Exception: if this file path cannot be opened. NrA )�modes rD �openzIFilePath.open� rF rG c � � y)zT Clear any cached information about the state of this path on disk. NrA rA rG rD �changedzIFilePath.changed� rF rG c � � y)z� Retrieve the size of this file in bytes. @return: the size of the file at this file path in bytes. @raise Exception: if the size cannot be obtained. NrA rA rG rD �getsizezIFilePath.getsize� rF rG c � � y)�� Retrieve the time of last access from this file. @return: a number of seconds from the epoch. @rtype: L{float} NrA rA rG rD �getModificationTimezIFilePath.getModificationTime� rF rG c � � y)�� Retrieve the time of the last status change for this file. @return: a number of seconds from the epoch. @rtype: L{float} NrA rA rG rD �getStatusChangeTimezIFilePath.getStatusChangeTime� rF rG c � � y)�� Retrieve the time that this file was last accessed. @return: a number of seconds from the epoch. @rtype: L{float} NrA rA rG rD � getAccessTimezIFilePath.getAccessTime� rF rG c � � y)z� Check if this file path exists. @return: C{True} if the file at this file path exists, C{False} otherwise. @rtype: L{bool} NrA rA rG rD r zIFilePath.exists� rF rG c � � y)z� Check if this file path refers to a directory. @return: C{True} if the file at this file path is a directory, C{False} otherwise. NrA rA rG rD �isdirzIFilePath.isdir� rF rG c � � y)z� Check if this file path refers to a regular file. @return: C{True} if the file at this file path is a regular file, C{False} otherwise. NrA rA rG rD �isfilezIFilePath.isfile� rF rG c � � y)z� List the children of this path object. @return: a sequence of the children of the directory at this file path. @raise Exception: if the file at this file path is not a directory. NrA rA rG rD �childrenzIFilePath.children� rF rG c � � y)a� Retrieve the final component of the file path's path (everything after the final path separator). @note: In implementors, the return type should be generic, i.e. C{AbstractFilePath[str].basename()} is a C{str}. However, L{Interface} objects cannot be generic as of this writing. @return: the base name of this file path. NrA rA rG rD r zIFilePath.basename� rF rG c � � y)zV A file path for the directory containing the file at this file path. NrA rA rG rD �parentzIFilePath.parent� rF rG c � � y)a$ A file path for the directory containing the file at this file path. @param name: the name of a sibling of this path. C{name} must be a direct sibling of this path and may not contain a path separator. @return: a sibling file path of this one. NrA rB s rD �siblingzIFilePath.sibling� rF rG N)rC r! �returnr? ��r�rI �FileModerd � IO[bytes]�rd �None�rd �int�rd �float�rd �bool)rd zIterable[IFilePath])rd �Union[str, bytes])rd r? )�__name__� __module__�__qualname__�__doc__r. �seprE rJ rL rN rQ rT rW r rZ r\ r^ r ra rc rA rG rD r? r? Z sZ � ��8 �I� J�C� ��� �������� �� rG r? c � � e Zd ZdZy)�InsecurePathzP Error that is raised when the path provided to L{FilePath} is invalid. N�rs rt ru rv rA rG rD ry ry � s � �rG ry c � � e Zd ZdZy)� LinkErrorz� An error with symlinks - either that there are cyclical symlinks or that symlink are not supported on this platform. Nrz rA rG rD r| r| � s � �rG r| c � � e Zd ZdZdd�Zy)�UnlistableErrorai An exception which is used to distinguish between errors which mean 'this is not a directory you can list' and other, more catastrophic errors. This error will try to look as much like the original error as possible, while still being catchable as an independent type. @ivar originalException: the actual original exception instance. c �\ � | j j |j � || _ y)zq Create an UnlistableError exception. @param originalException: an instance of OSError. N)�__dict__�update�originalException)�selfr� s rD �__init__zUnlistableError.__init__ s% � � � � ���.�7�7�8�!2��rG N)r� �OSError)rs rt ru rv r� rA rG rD r~ r~ � s � ��3rG r~ c �H � t t d� � dd }t | |� S )a Compute a string usable as a new, temporary filename. @param path: The path that the new temporary filename should be able to be concatenated with. @return: A pseudorandom, 16 byte string for use in secure filenames. @rtype: the type of C{path} � N)�armor�randomBytes�_coerceToFilesystemEncoding)�path�secureishStrings rD �_secureEnoughStringr� s&