Esempio n. 1
0
def assert_exists(*paths):
    module = caller_module()
    if not module:
        module = sys.modules[__name__]
    exc = type("IOError", (IOError, ), {})
    exc.__module__ = module.__name__
    for path in paths:
        path = str(path)
        if not os.path.exists(path):
            err = "No such file or directory: '%s'" % path
            raise exc(err)
Esempio n. 2
0
def all(module):
    """todo"""
    if not module:
        module = caller_module()
    kwargs = dict()
    if hasattr(module,"__all__"):
        keys = module.__all__
    else:
        keys = module.__dict__.keys()
    for k in keys:
        if k not in IGNORED:
            if k in module.__dict__:
                kwargs[k] = module.__dict__[k]
            else:
                err = "'%s' object has no attribute '%s'" % (module,k)
                raise AttributeError(err)
    return kwargs
#!/usr/bin/env python
from caller_module import caller_module

print("caller_module: %s" % caller_module())