From 8860bb05ab383c814ae0e849aa62787c9dd65f1e Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Fri, 26 Jun 2015 20:11:43 +0000
Subject: [PATCH] allow arbitrary args to be converted into dicts

---
 src/python/dm/common/cli/dmCli.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/python/dm/common/cli/dmCli.py b/src/python/dm/common/cli/dmCli.py
index 6660344f..4cde64ba 100755
--- a/src/python/dm/common/cli/dmCli.py
+++ b/src/python/dm/common/cli/dmCli.py
@@ -21,6 +21,8 @@ from dm.common.constants import dmStatus
 class DmCli(object):
     """ Base dm command line interface class. """
     DEFAULT_SESSION_CACHE_FILE = OsUtility.getUserHomeDir() + '/.dm/.session.cache'
+    ANY_NUMBER_OF_POSITIONAL_ARGS = 10000000
+
     def __init__(self, validArgCount=0):
         self.logger = LoggingManager.getInstance().getLogger(self.__class__.__name__)
         # Do not log into a file for CLIs
@@ -178,6 +180,19 @@ class DmCli(object):
         """ Returns the command line argument list. """
         return self.args
 
+    def splitArgsIntoDict(self, keyValueDelimiter=':'):
+        """ Returns the command line argument list as dictionary of key/value
+        pairs. Each argument is split using specified delimiter. """
+        argDict = {}
+        for a in self.args:
+            sList = a.split(keyValueDelimiter)
+            key = sList[0]
+            value = ''
+            if len(sList) > 1:
+                value = keyValueDelimiter.join(sList[1:])
+            argDict[key] = value
+        return argDict
+
     def getArg(self, i):
         """ Returns the i-th command line argument. """
         return self.args[i]
-- 
GitLab