o w[eU8 @sdZddlmZddlmZzddlZWney.Zzejdkr"dZWYdZ[ndZ[wwzddlZWn ey@eZYnwddl m Z ddl Z ddl Z ddl mZmZmZdd l mZmZd d ZGd d d e jdZGddde jdZeeejejejejGddde jdZeeejGddde ZGddde ZeeejejGdddeZeeej Gdddej!eeZ!ee!ej"ej#Gdddej$eeZ$ee$ej"Gddde jdZ%eGdd d eZ&Gd!d"d"e%Z'dS)#z(Abstract base classes related to import.)_bootstrap_external) machineryN_frozen_importlib)Loader)BinaryIOIterableText)Protocolruntime_checkablec GsZ|D](}||tdur*ztt|j}Wnty$tt|j}Ynw||qdSN)registerrgetattr__name__AttributeError_frozen_importlib_external) abstract_clsclassescls frozen_clsr$/usr/lib/python3.10/importlib/abc.py _registers   rc@s(eZdZdZddZejdddZdS)Findera<Legacy abstract base class for import finders. It may be subclassed for compatibility with legacy third party reimplementations of the import system. Otherwise, finder implementations should derive from the more specific MetaPathFinder or PathEntryFinder ABCs. Deprecated since Python 3.3 cCstdtdS)Nzqthe Finder ABC is deprecated and slated for removal in Python 3.12; use MetaPathFinder or PathEntryFinder insteadwarningswarnDeprecationWarningselfrrr__init__,szFinder.__init__NcCstdtdS)zAn abstract method that should find a module. The fullname is a str and the optional path is a str or None. Returns a Loader object or None. zimportlib.abc.Finder along with its find_module() method are deprecated and slated for removal in Python 3.12; use MetaPathFinder.find_spec() or PathEntryFinder.find_spec() insteadNr)rfullnamepathrrr find_module2szFinder.find_moduler )r __module__ __qualname____doc__r abcabstractmethodr#rrrrr s  r) metaclassc@s eZdZdZddZddZdS)MetaPathFinderz8Abstract base class for import finders on sys.meta_path.cCs<tjdtddt|dsdS|||}|dur|jSdS)a_Return a loader for the module. If no module is found, return None. The fullname is a str and the path is a list of strings or None. This method is deprecated since Python 3.4 in favor of finder.find_spec(). If find_spec() exists then backwards-compatible functionality is provided for this method. zMetaPathFinder.find_module() is deprecated since Python 3.4 in favor of MetaPathFinder.find_spec() and is slated for removal in Python 3.12 stacklevel find_specN)rrrhasattrr.loader)rr!r"foundrrrr#Gs   zMetaPathFinder.find_modulecCdS)zAn optional method for clearing the finder's cache, if any. This method is used by importlib.invalidate_caches(). Nrrrrrinvalidate_caches\z MetaPathFinder.invalidate_cachesN)rr$r%r&r#r3rrrrr*@s r*c@s&eZdZdZddZejZddZdS)PathEntryFinderz>Abstract base class for path entry finders used by PathFinder.cCsXtjdtddt|dsdgfS||}|dur(|js g}n|j}|j|fSdgfS)a[Return (loader, namespace portion) for the path entry. The fullname is a str. The namespace portion is a sequence of path entries contributing to part of a namespace package. The sequence may be empty. If loader is not None, the portion will be ignored. The portion will be discarded if another path entry finder locates the module as a normal module or package. This method is deprecated since Python 3.4 in favor of finder.find_spec(). If find_spec() is provided than backwards-compatible functionality is provided. zzPathEntryFinder.find_loader() is deprecated since Python 3.4 in favor of PathEntryFinder.find_spec() (available since 3.4)r+r,r.N)rrrr/r.submodule_search_locationsr0)rr!r1portionsrrr find_loaderls   zPathEntryFinder.find_loadercCr2)zAn optional method for clearing the finder's cache, if any. This method is used by PathFinder.invalidate_caches(). Nrrrrrr3r4z!PathEntryFinder.invalidate_cachesN) rr$r%r&r8r_find_module_shimr#r3rrrrr5es  r5c@seZdZdZejddZdS)ResourceLoaderzAbstract base class for loaders which can return data from their back-end storage. This ABC represents one of the optional protocols specified by PEP 302. cCt)zwAbstract method which when implemented should return the bytes for the specified path. The path must be a str.)OSErrorrr"rrrget_dataszResourceLoader.get_dataN)rr$r%r&r'r(r>rrrrr:sr:c@sLeZdZdZddZddZejddZe d d d Z e j j Z e j jZd S) InspectLoaderzAbstract base class for loaders which support inspection about the modules they can load. This ABC represents one of the optional protocols specified by PEP 302. cCr;)zOptional method which when implemented should return whether the module is a package. The fullname is a str. Returns a bool. Raises ImportError if the module cannot be found.  ImportErrorrr!rrr is_packagezInspectLoader.is_packagecCs ||}|dur dS||S)aMethod which returns the code object for the module. The fullname is a str. Returns a types.CodeType if possible, else returns None if a code object does not make sense (e.g. built-in module). Raises ImportError if the module cannot be found. N) get_sourcesource_to_code)rr!sourcerrrget_codes  zInspectLoader.get_codecCr;)zAbstract method which should return the source code for the module. The fullname is a str. Returns a str. Raises ImportError if the module cannot be found. r@rBrrrrEzInspectLoader.get_sourcecCst||dddS)zCompile 'data' into a code object. The 'data' argument can be anything that compile() can handle. The'path' argument should be where the data was retrieved (when applicable).execT) dont_inherit)compile)datar"rrrrFszInspectLoader.source_to_codeN)rJ)rr$r%r&rCrHr'r(rE staticmethodrFr _LoaderBasics exec_module load_modulerrrrr?s   r?c@s&eZdZdZejddZddZdS)ExecutionLoaderzAbstract base class for loaders that wish to support the execution of modules as scripts. This ABC represents one of the optional protocols specified in PEP 302. cCr;)zAbstract method which should return the value that __file__ is to be set to. Raises ImportError if the module cannot be found. r@rBrrr get_filenamerIzExecutionLoader.get_filenamecCsN||}|dur dSz||}Wnty ||YSw|||S)zMethod to return the code object for fullname. Should return None if not applicable (e.g. built-in module). Raise ImportError if the module cannot be found. N)rErTrArF)rr!rGr"rrrrHs   zExecutionLoader.get_codeN)rr$r%r&r'r(rTrHrrrrrSs   rSc@seZdZdZdS) FileLoaderz[Abstract base class partially implementing the ResourceLoader and ExecutionLoader ABCs.N)rr$r%r&rrrrrUsrUc@s(eZdZdZddZddZddZdS) SourceLoaderaAbstract base class for loading source code (and optionally any corresponding bytecode). To support loading from source code, the abstractmethods inherited from ResourceLoader and ExecutionLoader need to be implemented. To also support loading from bytecode, the optional methods specified directly by this ABC is required. Inherited abstractmethods not implemented in this ABC: * ResourceLoader.get_data * ExecutionLoader.get_filename cCs$|jjtjur tt||dS)z6Return the (int) modification time for the path (str).mtime) path_stats__func__rVr<intr=rrr path_mtimeszSourceLoader.path_mtimecCs |jjtjur td||iS)a Return a metadata dict for the source pointed to by the path (str). Possible keys: - 'mtime' (mandatory) is the numeric timestamp of last source code modification; - 'size' (optional) is the size in bytes of the source code. rW)r[rYrVr<r=rrrrX szSourceLoader.path_statscCr2)aWrite the bytes to the path (if possible). Accepts a str path and data as bytes. Any needed intermediary directories are to be created. If for some reason the file cannot be written because of permissions, fail silently. Nr)rr"rNrrrset_data+r4zSourceLoader.set_dataN)rr$r%r&r[rXr\rrrrrV s  rVc@speZdZdZejdedefddZejdedefddZ ejdede fd d Z ejde e fd d Zd S)ResourceReaderzDAbstract base class for loaders to provide resource reading support.resourcereturncCr;)zReturn an opened, file-like object for binary reading. The 'resource' argument is expected to represent only a file name. If the resource cannot be found, FileNotFoundError is raised. FileNotFoundErrorrr^rrr open_resource;s zResourceReader.open_resourcecCr;)zReturn the file system path to the specified resource. The 'resource' argument is expected to represent only a file name. If the resource does not exist on the file system, raise FileNotFoundError. r`rbrrr resource_pathGs zResourceReader.resource_pathr"cCr;)zjReturn True if the named 'path' is a resource. Files are resources, directories are not. r`r=rrr is_resourceTrDzResourceReader.is_resourcecCr;)z+Return an iterable of entries in `package`.r`rrrrcontents\szResourceReader.contentsN)rr$r%r&r'r(r rrcrdboolrerstrrfrrrrr]8s  r]c@seZdZdZejddZddZdddZejd e fd d Z ejd e fd d Z ejddZ ddZ ejdddZejd efddZdS) Traversablezt An object with a subset of pathlib.Path methods suitable for traversing directories and opening files. cCr2)z3 Yield Traversable objects in self Nrrrrriterdirir4zTraversable.iterdircCs6|d }|WdS1swYdS)z0 Read contents of self as bytes rbNopenread)rstrmrrr read_bytesos $zTraversable.read_bytesNcCs8|j|d }|WdS1swYdS)z/ Read contents of self as text )encodingNrl)rrqrorrr read_textvs$zTraversable.read_textr_cCr2)z. Return True if self is a dir Nrrrrris_dir}r4zTraversable.is_dircCr2)z/ Return True if self is a file Nrrrrris_filer4zTraversable.is_filecCr2)2 Return Traversable child in self Nrrchildrrrjoinpathr4zTraversable.joinpathcCs ||S)ru)rxrvrrr __truediv__s zTraversable.__truediv__rcOr2)z mode may be 'r' or 'rb' to open as text or binary. Return a handle suitable for reading (same as pathlib.Path.open). When opening as text, accepts encoding parameters such as those accepted by io.TextIOWrapper. Nr)rmodeargskwargsrrrrmr4zTraversable.opencCr2)zM The base name of this object without any parent references. Nrrrrrnamer4zTraversable.namer )rz)rr$r%r&r'r(rjrprrrgrsrtrxryrmabstractpropertyrhr~rrrrribs"     ric@s>eZdZdZejddZddZddZdd Z d d Z d S) TraversableResourceszI The required interface for providing traversable resources. cCr2)z3Return a Traversable object for the loaded package.Nrrrrrfilesr4zTraversableResources.filescCs||dS)Nrk)rrxrmrbrrrrcsz"TraversableResources.open_resourcecCst|r r`rbrrrrdsz"TraversableResources.resource_pathcCs||Sr )rrxrtr=rrrresz TraversableResources.is_resourcecCsdd|DS)Ncss|]}|jVqdSr )r~).0itemrrr sz0TraversableResources.contents..)rrjrrrrrfszTraversableResources.contentsN) rr$r%r&r'r(rrcrdrerfrrrrrs  r)(r&rrrrAexcr~r_abcrr'rtypingrrr r r rABCMetarr*BuiltinImporterFrozenImporter PathFinderWindowsRegistryFinderr5 FileFinderr:r?rSExtensionFileLoaderrUSourceFileLoaderSourcelessFileLoaderrVr]rirrrrrsX         ! .2 " ,*C