Last active
February 22, 2019 02:42
-
-
Save ResidentMario/de0b533cab52bf5635418a04724b99a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from importlib.machinery import ModuleSpec | |
class DataPackageFinder: | |
""" | |
Data package module loader finder. This class sits on `sys.meta_path` and returns the | |
loader it knows for a given path, if it knows a compatible loader. | |
""" | |
@classmethod | |
def find_spec(cls, fullname, path=None, target=None): | |
""" | |
This functions is what gets executed by the loader. | |
""" | |
name_parts = fullname.split('.') | |
if name_parts[:2] != ['t4', 'data'] or len(name_parts) > 3: | |
return None | |
else: | |
return ModuleSpec(fullname, DataPackageImporter()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment