Created
September 9, 2016 06:22
-
-
Save ajayhn/ab379ae36a0e07d101e4861587541828 to your computer and use it in GitHub Desktop.
satisfy any import from vnc_api.types.
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
in vnc_api/__init__.py | |
``` | |
import sys | |
import imp | |
class MyImportFinder(object): | |
def find_module(self, fullname, path=None): | |
print fullname | |
if fullname.startswith('vnc_api.types'): | |
return self | |
return None | |
def load_module(self, fullname): | |
print "need to load " + fullname | |
if fullname in sys.modules: | |
mod = sys.modules[fullname] | |
else: | |
mod = sys.modules.setdefault(fullname, imp.new_module(fullname)) | |
# Set a few properties required by PEP 302 | |
mod.__file__ = fullname | |
mod.__name__ = fullname | |
# always looks like a package | |
mod.__path__ = [ 'path-entry-goes-here' ] | |
mod.__loader__ = self | |
mod.__package__ = '.'.join(fullname.split('.')[:-1]) | |
return mod | |
``` | |
mkdir vnc_api/types | |
touch vnc_api/types/__init__.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment