]> code.communitydata.science - covid19.git/blobdiff - wikipedia/scripts/digobs.py
changes in response to code review by nate
[covid19.git] / wikipedia / scripts / digobs.py
diff --git a/wikipedia/scripts/digobs.py b/wikipedia/scripts/digobs.py
new file mode 100644 (file)
index 0000000..0bce250
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import sys
+import subprocess
+import logging
+
+def git_hash(short=False):
+    if short:
+        return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode().strip()
+    else:
+        subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()
+
+def get_loglevel(arg_loglevel):
+    loglevel_mapping = { 'debug' : logging.DEBUG,
+                         'info' : logging.INFO,
+                         'warning' : logging.WARNING,
+                         'error' : logging.ERROR,
+                         'critical' : logging.CRITICAL }
+
+    if arg_loglevel in loglevel_mapping:
+        loglevel = loglevel_mapping[arg_loglevel]
+        return loglevel
+    else:
+        print("Choose a valid log level: debug, info, warning, error, or critical", file=sys.stderr)
+        return logging.INFO
+
+

Community Data Science Collective || Want to submit a patch?