summaryrefslogtreecommitdiff
path: root/.local/share/Anki2/addons21/anki_reworked/utils/modules.py
blob: fc55a1280292ee17323eb0f0442f367086c74db4 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True

def module_has_attribute(module_name, attribute):
    if module_exists(module_name):
        return hasattr(__import__(module_name), attribute)
    return False

def attribute_exists(object, attribute):
    return attribute in object.__dict__

def context_name_includes(context, classname):
    return classname in str(context.__class__)