o ?OgU8 @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)Z abstract_clsZclassesclsZ frozen_clsr4/opt/alt/python310/lib64/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__rabcabstractmethodr 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)rrrfoundrrrr 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 r0rrrrr'@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_locationsr-)rrr.portionsrrr find_loaderls   zPathEntryFinder.find_loadercCr/)zAn optional method for clearing the finder's cache, if any. This method is used by PathFinder.invalidate_caches(). Nrrrrrr0r1z!PathEntryFinder.invalidate_cachesN) rr!r"r#r5r_find_module_shimr r0rrrrr2es  r2c@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.)OSErrorrrrrrget_dataszResourceLoader.get_dataN)rr!r"r#r$r%r;rrrrr7sr7c@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. cCr8)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.  ImportErrorrrrrr 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)rrsourcerrrget_codes  zInspectLoader.get_codecCr8)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=r?rrrrBzInspectLoader.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)datarrrrrCszInspectLoader.source_to_codeN)rG)rr!r"r#r@rEr$r%rB staticmethodrCr _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. cCr8)zAbstract method which should return the value that __file__ is to be set to. Raises ImportError if the module cannot be found. r=r?rrr get_filenamerFzExecutionLoader.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)rBrQr>rC)rrrDrrrrrEs   zExecutionLoader.get_codeN)rr!r"r#r$r%rQrErrrrrPs   rPc@seZdZdZdS) FileLoaderz[Abstract base class partially implementing the ResourceLoader and ExecutionLoader ABCs.N)rr!r"r#rrrrrRsrRc@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__rSr9intr: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. rT)rXrVrSr9r:rrrrU szSourceLoader.path_statscCr/)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)rrrKrrrset_data+r1zSourceLoader.set_dataN)rr!r"r#rXrUrYrrrrrS s  rSc@speZdZdZejdedefddZejdedefddZ ejdede fd d Z ejde e fd d Zd S)ResourceReaderzDAbstract base class for loaders to provide resource reading support.resourcereturncCr8)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_resourcecCr8)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]r_rrr resource_pathGs zResourceReader.resource_pathrcCr8)zjReturn True if the named 'path' is a resource. Files are resources, directories are not. r]r:rrr is_resourceTrAzResourceReader.is_resourcecCr8)z+Return an iterable of entries in `package`.r]rrrrcontents\szResourceReader.contentsN)rr!r"r#r$r%r rr`raboolrbrstrrcrrrrrZ8s  rZc@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. cCr/)z3 Yield Traversable objects in self Nrrrrriterdirir1zTraversable.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 )encodingNri)rrnrlrrr read_textvs$zTraversable.read_textr\cCr/)z. Return True if self is a dir Nrrrrris_dir}r1zTraversable.is_dircCr/)z/ Return True if self is a file Nrrrrris_filer1zTraversable.is_filecCr/)2 Return Traversable child in self Nrrchildrrrjoinpathr1zTraversable.joinpathcCs ||S)rr)rursrrr __truediv__s zTraversable.__truediv__rcOr/)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)rmodeargskwargsrrrrjr1zTraversable.opencCr/)zM The base name of this object without any parent references. Nrrrrrnamer1zTraversable.namer )rw)rr!r"r#r$r%rgrmrordrprqrurvrjabstractpropertyrer{rrrrrfbs"     rfc@s>eZdZdZejddZddZddZdd Z d d Z d S) TraversableResourceszI The required interface for providing traversable resources. cCr/)z3Return a Traversable object for the loaded package.Nrrrrrfilesr1zTraversableResources.filescCs||dS)Nrh)r~rurjr_rrrr`sz"TraversableResources.open_resourcecCst|r r]r_rrrrasz"TraversableResources.resource_pathcCs||Sr )r~rurqr:rrrrbsz TraversableResources.is_resourcecCsdd|DS)Ncss|]}|jVqdSr )r{).0itemrrr sz0TraversableResources.contents..)r~rgrrrrrcszTraversableResources.contentsN) rr!r"r#r$r%r~r`rarbrcrrrrr}s  r})(r#rrrr>excr{r_abcrr$rtypingrrr r r rABCMetarr'BuiltinImporterFrozenImporter PathFinderWindowsRegistryFinderr2 FileFinderr7r<rPExtensionFileLoaderrRSourceFileLoaderSourcelessFileLoaderrSrZrfr}rrrrsX         ! .2 " ,*C