/usr/local/lib64/python3.6/site-packages/torch/package/__pycache__
NameSizeModeActions
file_structure_representation.cpython-36.pyc44980644editdlrm
find_file_dependencies.cpython-36.pyc32270644editdlrm
glob_group.cpython-36.pyc45130644editdlrm
importer.cpython-36.pyc71110644editdlrm
package_exporter.cpython-36.pyc340530644editdlrm
package_importer.cpython-36.pyc205860644editdlrm
_digraph.cpython-36.pyc28780644editdlrm
_directory_reader.cpython-36.pyc26590644editdlrm
_importlib.cpython-36.pyc23740644editdlrm
_mangling.cpython-36.pyc21250644editdlrm
_mock.cpython-36.pyc27420644editdlrm
_package_pickler.cpython-36.pyc27260644editdlrm
_package_unpickler.cpython-36.pyc11770644editdlrm
_stdlib.cpython-36.pyc63990644editdlrm
__init__.cpython-36.pyc6260644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/package/__pycache__/importer.cpython-36.pyc (7111B)
3 Eg @sddlZddlmZmZddlmZmZddlmZddl m Z ddl m Z m Z mZmZmZddlmZmZmZGd d d eZGd d d eZGd ddeZGdddeZeZGdddeZdS)N)ABCabstractmethod) _getattribute_Pickler) whichmodule) ModuleType)AnyListOptionalTupleDict)demangleget_mangle_prefix is_mangledc@seZdZdZdS)ObjNotFoundErrorzHRaised when an importer cannot find an object by searching for its name.N)__name__ __module__ __qualname____doc__rrB/usr/local/lib64/python3.6/site-packages/torch/package/importer.pyr src@seZdZdZdS)ObjMismatchErrorz]Raised when an importer found a different object with the same name as the user-provided one.N)rrrrrrrrrsrc@sdeZdZUdZeeefeeedddZ d e e ee eefdddZ e eedd d ZdS) ImporteradRepresents an environment to import modules from. By default, you can figure out what module an object belongs by checking __module__ and importing the result using __import__ or importlib.import_module. torch.package introduces module importers other than the default one. Each PackageImporter introduces a new namespace. Potentially a single name (e.g. 'foo.bar') is present in multiple namespaces. It supports two main operations: import_module: module_name -> module object get_name: object -> (parent module name, name of obj within module) The guarantee is that following round-trip will succeed or throw an ObjNotFoundError/ObjMisMatchError. module_name, obj_name = env.get_name(obj) module = env.import_module(module_name) obj2 = getattr(module, obj_name) assert obj1 is obj2 ) module_namereturncCsdS)zvImport `module_name` from this environment. The contract is the same as for importlib.import_module. Nr)selfrrrr import_module.szImporter.import_moduleN)objnamercsZdkrb|rbtjjt|dkrbt|dd}|dk rby|}t|trJ|Wntk r`YnXdkrvt|dddkr|jj |}t |}yj |}t |\}} Wn4t ttfk rt|d|ddYnX||kr|fSfdd} | |\} } } | |\}}}d| d | d |d |d | d |d }t|dS)amGiven an object, return a name that can be used to retrieve the object from this environment. Args: obj: An object to get the the module-environment-relative name for. name: If set, use this name instead of looking up __name__ or __qualname__ on `obj`. This is only here to match how Pickler handles __reduce__ functions that return a string, don't use otherwise. Returns: A tuple (parent_module_name, attr_name) that can be used to retrieve `obj` from this environment. Use it like: mod = importer.import_module(parent_module_name) obj = getattr(mod, attr_name) Raises: ObjNotFoundError: we couldn't retrieve `obj by name. ObjMisMatchError: we found a different object with the same name as `obj`. N __reduce__rz was not found as .csPdk s tj|}t|}|r,t|nd}|rBdt|nd}|||fS)Nzthe current Python environmentzthe importer for z'sys_importer')AssertionErrorrrr)rrZ is_mangled_locationZ importer_name)rrrr get_obj_infols   z'Importer.get_name..get_obj_infoz The object provided is from 'z', which is coming from z. However, when we import 'z', it's coming from z@. To fix this, make sure this 'PackageExporter's importer lists z before )rdispatchgettypegetattr isinstancestr Exceptionrrrrr ImportErrorKeyErrorAttributeErrorrr)rrrreducervZorig_module_namermoduleobj2_r$Zobj_module_nameZ obj_locationZobj_importer_nameZobj2_module_nameZ obj2_locationZobj2_importer_namemsgr)rrrget_name6s:       *zImporter.get_namec Cst|dd}|dk r|Sxd|jjjD]R\}}|dks(|dks(|dkrJq(yt||d|krb|SWq(tk rxYq(Xq(WdS)aFind the module name an object belongs to. This should be considered internal for end-users, but developers of an importer can override it to customize the behavior. Taken from pickle.py, but modified to exclude the search into sys.modules rN__main__ __mp_main__r)r(modulescopyitemsrr.)rrrrr1rrrrs  zImporter.whichmodule)N)rrrrr r*rr8rrrr r r5rrrrrrs   Qrc@s0eZdZdZedddZeeedddZdS) _SysImporterz;An importer that implements the default behavior of Python.)rcCs tj|S)N) importlibr)rrrrrrsz_SysImporter.import_module)rrrcCs t||S)N)_pickle_whichmodule)rrrrrrrsz_SysImporter.whichmoduleN)rrrrr*rrrrrrrr;sr;c@s:eZdZdZddZeedddZeeeddd Z d S) OrderedImporterzA compound importer that takes a list of importers and tries them one at a time. The first importer in the list that returns a result "wins". cGst||_dS)N)list _importers)rargsrrr__init__szOrderedImporter.__init__)rrcCsxd}xX|jD]N}t|ts(t|dy |j|Stk rX}z |}WYdd}~Xq Xq W|dk rl|nt|dS)NzP is not a Importer. All importers in OrderedImporter must inherit from Importer.)r@r)r TypeErrorrModuleNotFoundError)rrZlast_errimportererrrrrrs    zOrderedImporter.import_module)rrrcCs,x&|jD]}|j||}|dkr|SqWdS)Nr6)r@r)rrrrErrrrrs   zOrderedImporter.whichmoduleN) rrrrrBr*rrrrrrrrr>sr>)r<abcrrpicklerrrr=typesrtypingrr r r r Z _manglingrrrr+rrrr;Z sys_importerr>rrrrs