Skip to content

Instantly share code, notes, and snippets.

@ajayhn
Created September 9, 2016 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajayhn/ab379ae36a0e07d101e4861587541828 to your computer and use it in GitHub Desktop.
Save ajayhn/ab379ae36a0e07d101e4861587541828 to your computer and use it in GitHub Desktop.
satisfy any import from vnc_api.types.
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