summaryrefslogtreecommitdiff
path: root/domestic/utility/validate_dict_key.py
diff options
context:
space:
mode:
Diffstat (limited to 'domestic/utility/validate_dict_key.py')
-rw-r--r--domestic/utility/validate_dict_key.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/domestic/utility/validate_dict_key.py b/domestic/utility/validate_dict_key.py
new file mode 100644
index 0000000..18e246b
--- /dev/null
+++ b/domestic/utility/validate_dict_key.py
@@ -0,0 +1,10 @@
+def validate_dict_key(dictionary, key, lower=True):
+ try:
+ if lower:
+ return dictionary[key].lower()
+ else:
+ return dictionary[key]
+ except KeyError:
+ return None
+ except:
+ return dictionary[key] \ No newline at end of file