From 6256d54c459a1502cf696f35a3b5a434cb11dae1 Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Wed, 2 Dec 2015 17:22:55 +0000
Subject: [PATCH] utility for dictionary manipulation

---
 src/python/dm/common/utility/dictUtility.py | 26 +++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 src/python/dm/common/utility/dictUtility.py

diff --git a/src/python/dm/common/utility/dictUtility.py b/src/python/dm/common/utility/dictUtility.py
new file mode 100755
index 00000000..3e357d6d
--- /dev/null
+++ b/src/python/dm/common/utility/dictUtility.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+import copy
+
+class DictUtility:
+
+    @classmethod
+    def deepCopy(cls, dict, includeKeys=[], excludeKeys=[]):
+        dict2 = copy.deepcopy(dict)
+        if len(includeKeys):
+            for key in dict2.keys():
+                if not key in includeKeys:
+                    del dict2[key]
+        elif len(excludeKeys):
+            for key in excludeKeys:
+                if dict2.has_key(key):
+                    del dict2[key]
+        return dict2
+
+#######################################################################
+# Testing.
+if __name__ == '__main__':
+    print DictUtility.deepCopy({'k1': '1', 'k2' : '2'}, excludeKeys=['k1'])
+    print  DictUtility.deepCopy({'k1': '1', 'k2' : '2'}, includeKeys=['k1'])
+    print  DictUtility.deepCopy({'k1': '1', 'k2' : '2'})
+
-- 
GitLab