1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 __author__ = "Karl Levik"
30 __contact__ = "karl.levik@diamnd.ac.uk"
31 __license__ = "LGPLv3+"
32 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
33
34 import shlex
35
37 """
38 Base class for command line objects.
39 """
40
41 - def __init__(self, _strCommandLineArgument=None):
42 self.__strCommand = None
43 self.__listCommandLineArgument = []
44 if (isinstance(_strCommandLineArgument, str)):
45 self.__strCommand = _strCommandLineArgument
46 self.__listCommandLineArgument = shlex.split(self.__strCommand)
47 elif (isinstance(_strCommandLineArgument, list)):
48 self.__listCommandLineArgument = []
49 for cmdkey in _strCommandLineArgument:
50 self.__listCommandLineArgument.append(cmdkey)
51
52
54 if (self.__listCommandLineArgument != None):
55 self.__strCommand = ""
56 for cmdkey in self.__listCommandLineArgument:
57 self.__strCommand += cmdkey + " "
58 return self.__strCommand
59
60
62 return self.__listCommandLineArgument
63
64
66 return _str in self.__listCommandLineArgument
67
68
70 for i in range(0, len(self.__listCommandLineArgument)):
71 strArgument = self.__listCommandLineArgument[i]
72 if (strArgument == _str):
73 j = i + 1
74 if j < len(self.__listCommandLineArgument):
75 return self.__listCommandLineArgument[j]
76 return None
77