Esempio n. 1
7
from imp import find_module
from pkgutil import ImpImporter
from os.path import *

for a in (imp.PY_SOURCE,
          imp.PY_COMPILED,
          imp.C_EXTENSION,
          imp.PY_RESOURCE,
          imp.PKG_DIRECTORY,
          imp.C_BUILTIN,
          imp.PY_FROZEN):
    print a


modname = 'signal'
mod = ImpImporter().find_module(modname)
print 'mod', mod
print 'filename', mod.get_filename()
print 'source', mod.get_source()
print 'code', mod.get_code()
print 'file', mod.file
print 'etc', mod.etc
## print 'ispackage', mod.is_package('util')
## print 'data', mod.get_data()

for a in dir(mod):
    v = getattr(mod, a)
    print a, v


Esempio n. 2
0
def find_mod(modname, fn):

    print('\n\n\n-----', modname, fn)

    mod = ImpImporter().find_module(modname)
    print('global', mod, mod and mod.get_filename())

    mod = ImpImporter(dirname(fn)).find_module(modname)
    print('local', mod, mod and mod.get_filename())

    try:
        mod = find_module(modname)
    except ImportError:
        mod = 'ERROR'
    print('imp global', mod)

    try:
        mod = find_module(modname, dirname(fn))
    except ImportError:
        mod = 'ERROR'
    print('imp local', mod)
Esempio n. 3
0
def find_mod(modname, fn):

    print '\n\n\n-----', modname, fn

    mod = ImpImporter().find_module(modname)
    print 'global', mod, mod and mod.get_filename()

    mod = ImpImporter(dirname(fn)).find_module(modname)
    print 'local', mod, mod and mod.get_filename()

    try:
        mod = find_module(modname)
    except ImportError:
        mod = 'ERROR'
    print 'imp global', mod

    try:
        mod = find_module(modname, dirname(fn))
    except ImportError:
        mod = 'ERROR'
    print 'imp local', mod
Esempio n. 4
0
#!/usr/bin/env python
import types, imp
from imp import find_module
from pkgutil import ImpImporter
from os.path import *

for a in (imp.PY_SOURCE, imp.PY_COMPILED, imp.C_EXTENSION, imp.PY_RESOURCE,
          imp.PKG_DIRECTORY, imp.C_BUILTIN, imp.PY_FROZEN):
    print a

modname = 'signal'
mod = ImpImporter().find_module(modname)
print 'mod', mod
print 'filename', mod.get_filename()
print 'source', mod.get_source()
print 'code', mod.get_code()
print 'file', mod.file
print 'etc', mod.etc
## print 'ispackage', mod.is_package('util')
## print 'data', mod.get_data()

for a in dir(mod):
    v = getattr(mod, a)
    print a, v