î e fì(ã@s÷dZddlmZddlmZyddlZWn@ek rxZz ejdkr`‚ndZWYddZ[XnXddlZdd„Z Gd d „d d ej ƒZ Gd d „d e ƒZ e e ej ejejejƒGdd„de ƒZe eejƒGdd„dd ej ƒZGdd„deƒZGdd„deƒZe eej ejƒGdd„deƒZe eejƒGdd„dejeeƒZe eejejƒGdd„dejeeƒZe eejƒdS)z(Abstract base classes related to import.é)Ú _bootstrap)Ú machineryéNÚ_frozen_importlibcGsPxI|D]A}|j|ƒtdk rtt|jƒ}|j|ƒqqWdS)N)ÚregisterrÚgetattrÚ__name__)Z abstract_clsZclassesÚclsZ frozen_cls©r ú2/opt/alt/python34/lib64/python3.4/importlib/abc.pyÚ _register s    r c@s.eZdZdZejddd„ƒZdS)ÚFinderaLegacy 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. NcCsdS)z¥An 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. Nr )ÚselfÚfullnameÚpathr r r Ú find_moduleszFinder.find_module)rÚ __module__Ú __qualname__Ú__doc__ÚabcÚabstractmethodrr r r r r s r Ú metaclassc@s.eZdZdZdd„Zdd„ZdS)ÚMetaPathFinderz8Abstract base class for import finders on sys.meta_path.cCs<t|dƒsdS|j||ƒ}|dk r8|jSdS)aNReturn 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 in favor of finder.find_spec(). If find_spec() exists then backwards-compatible functionality is provided for this method. Ú find_specN)ÚhasattrrÚloader)rrrÚfoundr r r r.s zMetaPathFinder.find_modulecCsdS)z‚An optional method for clearing the finder's cache, if any. This method is used by importlib.invalidate_caches(). Nr )rr r r Úinvalidate_caches>sz MetaPathFinder.invalidate_cachesN)rrrrrrr r r r r's  rc@s7eZdZdZdd„ZejZdd„ZdS)ÚPathEntryFinderz>Abstract base class for path entry finders used by PathFinder.cCsjt|dƒsdgfS|j|ƒ}|dk r\|jsFg}n |j}|j|fSdgfSdS)aCReturn (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 in favor of finder.find_spec(). If find_spec() is provided than backwards-compatible functionality is provided. rN)rrÚsubmodule_search_locationsr)rrrÚportionsr r r Ú find_loaderNs      zPathEntryFinder.find_loadercCsdS)zƒAn optional method for clearing the finder's cache, if any. This method is used by PathFinder.invalidate_caches(). Nr )rr r r rksz!PathEntryFinder.invalidate_cachesN) rrrrr!rÚ_find_module_shimrrr r r r rGs   rc@s:eZdZdZdd„Zdd„Zdd„ZdS) ÚLoaderz'Abstract base class for import loaders.cCsdS)a#Return a module to initialize and into which to load. This method should raise ImportError if anything prevents it from creating a new module. It may return None to indicate that the spec should create the new module. create_module() is optional. Nr )rÚspecr r r Ú create_modulews zLoader.create_modulecCs(t|dƒst‚ntj||ƒS)aŽReturn the loaded module. The module must be added to sys.modules and have import-related attributes set properly. The fullname is a str. ImportError is raised on failure. This method is deprecated in favor of loader.exec_module(). If exec_module() exists then it is used to provide a backwards-compatible functionality for this method. Ú exec_module)rÚ ImportErrorrÚ_load_module_shim)rrr r r Ú load_module‡s  zLoader.load_modulecCs t‚dS)z¢Return a module's repr. Used by the module type when the method does not raise NotImplementedError. This method is deprecated. N)ÚNotImplementedError)rÚmoduler r r Ú module_repr˜s zLoader.module_reprN)rrrrr%r)r,r r r r r#ss   r#c@s+eZdZdZejdd„ƒZdS)ÚResourceLoaderz©Abstract 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. cCs t‚dS)zwAbstract method which when implemented should return the bytes for the specified path. The path must be a str.N)ÚIOError)rrr r r Úget_data®szResourceLoader.get_dataN)rrrrrrr/r r r r r-¥s r-c@sjeZdZdZdd„Zdd„Zejdd„ƒZdd d „Z e j j Z e j j Z d S) Ú InspectLoaderz°Abstract 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. cCs t‚dS)zÊOptional 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. N)r')rrr r r Ú is_package¾szInspectLoader.is_packagecCs,|j|ƒ}|dkrdS|j|ƒ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_sourceÚsource_to_code)rrÚsourcer r r Úget_codeÆs zInspectLoader.get_codecCs t‚dS)z·Abstract 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. N)r')rrr r r r2ÓszInspectLoader.get_sourcezcCst||dddƒS)z¿Compile '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).ÚexecÚ dont_inheritT)Úcompile)rÚdatarr r r r3ÜszInspectLoader.source_to_codeN)rrrrr1r5rrr2r3rÚ _LoaderBasicsr&r)r r r r r0µs     r0c@s7eZdZdZejdd„ƒZdd„ZdS)ÚExecutionLoaderz°Abstract 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. cCs t‚dS)z˜Abstract method which should return the value that __file__ is to be set to. Raises ImportError if the module cannot be found. N)r')rrr r r Ú get_filenameòszExecutionLoader.get_filenamec Csh|j|ƒ}|dkrdSy|j|ƒ}Wntk rS|j|ƒSYnX|j||ƒSdS)z¶Method 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)r2r<r'r3)rrr4rr r r r5ûs  zExecutionLoader.get_codeN)rrrrrrr<r5r r r r r;és  r;c@seZdZdZdS)Ú FileLoaderz[Abstract base class partially implementing the ResourceLoader and ExecutionLoader ABCs.N)rrrrr r r r r=s r=c@s:eZdZdZdd„Zdd„Zdd„ZdS) Ú SourceLoaderaäAbstract 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 cCs5|jjtjkrt‚nt|j|ƒdƒS)z6Return the (int) modification time for the path (str).Úmtime)Ú path_statsÚ__func__r>r.Úint)rrr r r Ú path_mtime(s zSourceLoader.path_mtimecCs2|jjtjkrt‚ni|j|ƒd6S)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. r?)rCrAr>r.)rrr r r r@.s zSourceLoader.path_statscCsdS)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 )rrr9r r r Úset_data9szSourceLoader.set_dataN)rrrrrCr@rDr r r r r>s   r>)rÚrrrr'ÚexcÚnamerr ÚABCMetar rÚBuiltinImporterÚFrozenImporterÚ PathFinderÚWindowsRegistryFinderrÚ FileFinderr#r-r0r;ÚExtensionFileLoaderr=ÚSourceFileLoaderÚSourcelessFileLoaderr>r r r r Ús6  )21"  ,