summaryrefslogtreecommitdiff
path: root/.local/share/Anki2/addons21/anki_reworked/utils/modules.py
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2022-08-04 09:50:48 +0300
committerThanos Apollo <[email protected]>2022-08-04 09:50:48 +0300
commit4ddb7273098bee179bb77e0937e560fc0100960c (patch)
treecebc2f9412e45910408a7885ca78d7dedb77de78 /.local/share/Anki2/addons21/anki_reworked/utils/modules.py
parente83759ae9d0513024e390810ddcb18ffdd84675e (diff)
Add anki addons
Diffstat (limited to '.local/share/Anki2/addons21/anki_reworked/utils/modules.py')
-rw-r--r--.local/share/Anki2/addons21/anki_reworked/utils/modules.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/.local/share/Anki2/addons21/anki_reworked/utils/modules.py b/.local/share/Anki2/addons21/anki_reworked/utils/modules.py
new file mode 100644
index 0000000..fc55a12
--- /dev/null
+++ b/.local/share/Anki2/addons21/anki_reworked/utils/modules.py
@@ -0,0 +1,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__) \ No newline at end of file