How to use the pyodesys.util.MissingImport function in pyodesys

To help you get started, we’ve selected a few pyodesys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bjodah / pyodesys / pyodesys / util.py View on Github external
def import_(modname, *args):
    if len(args) == 0:
        try:
            return __import__(modname)
        except ImportError as e:
            return MissingImport(modname, e)

    mods = []
    for arg in args:
        try:
            mod = __import__(modname, globals(), locals(), [arg])
        except ImportError as e:
            mods.append(MissingImport(modname + '.' + arg, e))
        else:
            try:
                attr = getattr(mod, arg)
            except AttributeError as e:
                mods.append(MissingImport(modname + '.' + arg, e))
            else:
                mods.append(attr)
    return mods if len(args) > 1 else mods[0]
github bjodah / pyodesys / pyodesys / util.py View on Github external
def import_(modname, *args):
    if len(args) == 0:
        try:
            return __import__(modname)
        except ImportError as e:
            return MissingImport(modname, e)

    mods = []
    for arg in args:
        try:
            mod = __import__(modname, globals(), locals(), [arg])
        except ImportError as e:
            mods.append(MissingImport(modname + '.' + arg, e))
        else:
            try:
                attr = getattr(mod, arg)
            except AttributeError as e:
                mods.append(MissingImport(modname + '.' + arg, e))
            else:
                mods.append(attr)
    return mods if len(args) > 1 else mods[0]