|
Gaudi Framework, version v23r4 |
| Home | Generated: Mon Sep 17 2012 |
Public Member Functions | |
| def | __init__ |
| def | name |
| def | set |
| def | unset |
| def | value |
| def | remove_regexp |
| def | remove |
| def | append |
| def | prepend |
| def | search |
| def | repl |
| def | resolveReferences |
| def | __getitem__ |
| def | __setitem__ |
| def | __delitem__ |
| def | __iter__ |
| def | __contains__ |
| def | __len__ |
| def | __str__ |
Public Attributes | |
| report | |
| varName | |
| local | |
| val | |
Private Member Functions | |
| def | _changeSlashes |
| def | _concatenate |
| def | _remDuplicates |
Class for manipulating with environment lists. It holds its name and values represented by a list. Some operations are done with separator, which is usually colon. For windows use semicolon.
Definition at line 10 of file Variable.py.
| def EnvConfig::Variable::List::__init__ | ( | self, | |
| name, | |||
local = False, |
|||
report = None |
|||
| ) |
Definition at line 18 of file Variable.py.
| def EnvConfig::Variable::List::__contains__ | ( | self, | |
| item | |||
| ) |
Definition at line 215 of file Variable.py.
| def EnvConfig::Variable::List::__delitem__ | ( | self, | |
| key | |||
| ) |
Definition at line 208 of file Variable.py.
| def EnvConfig::Variable::List::__getitem__ | ( | self, | |
| key | |||
| ) |
Definition at line 199 of file Variable.py.
| def EnvConfig::Variable::List::__iter__ | ( | self ) |
Definition at line 211 of file Variable.py.
| def EnvConfig::Variable::List::__len__ | ( | self ) |
Definition at line 218 of file Variable.py.
| def EnvConfig::Variable::List::__setitem__ | ( | self, | |
| key, | |||
| value | |||
| ) |
Definition at line 202 of file Variable.py.
| def EnvConfig::Variable::List::__str__ | ( | self ) |
Definition at line 221 of file Variable.py.
| def EnvConfig::Variable::List::_changeSlashes | ( | self, | |
| value | |||
| ) | [private] |
Changes slashes depending on operating system.
Definition at line 154 of file Variable.py.
00155 : 00156 '''Changes slashes depending on operating system.''' 00157 i = 0 00158 while i < len(value): 00159 if len(value[i]) == 0: 00160 del value[i] 00161 continue 00162 if value[i][0] == '[': 00163 if platform.system() != 'Linux': 00164 value[i] = value[i][1:] 00165 else: 00166 value[i] = value[i][3:] 00167 value[i] = os.path.normpath(value[i]) 00168 i+=1 00169 return value 00170
| def EnvConfig::Variable::List::_concatenate | ( | self, | |
| separator | |||
| ) | [private] |
Returns a List string with separator "separator" from the values list
Definition at line 171 of file Variable.py.
| def EnvConfig::Variable::List::_remDuplicates | ( | self, | |
| seq, | |||
idfun = None |
|||
| ) | [private] |
removes duplicated values from list
Definition at line 181 of file Variable.py.
00182 : 00183 '''removes duplicated values from list''' 00184 if idfun is None: 00185 def idfun(x): return x 00186 seen = {} 00187 result = [] 00188 for item in seq: 00189 marker = idfun(item) 00190 00191 if marker in seen: 00192 self.report.addWarn('Var: "'+self.varName+'" value: "' + marker + '". Addition canceled because of duplicate entry.') 00193 continue 00194 seen[marker] = 1 00195 result.append(item) 00196 return result 00197 00198
| def EnvConfig::Variable::List::append | ( | self, | |
| value, | |||
separator = ':', |
|||
environment = {}, |
|||
warningOn = True |
|||
| ) |
Adds value(s) at the end of the list.
Definition at line 74 of file Variable.py.
00074 :', environment={}, warningOn=True): 00075 '''Adds value(s) at the end of the list.''' 00076 00077 value = self.resolveReferences(value, environment, separator) 00078 00079 if type(value) is str: 00080 value = value.split(separator) 00081 00082 if warningOn: 00083 notPresent = lambda v: v not in self.val 00084 else: 00085 def notPresent(v): 00086 '''helper function to report duplicated entries''' 00087 if v not in self.val: 00088 return True 00089 else: 00090 self.report.addWarn('Var: "'+self.varName+'" value: "' + v + '". Addition canceled because of duplicate entry.') 00091 return False 00092 # add to the end of self.val the values not already there 00093 self.val += filter(notPresent, value) 00094
| def EnvConfig::Variable::List::name | ( | self ) |
Returns the name of the List.
Definition at line 24 of file Variable.py.
| def EnvConfig::Variable::List::prepend | ( | self, | |
| value, | |||
separator = ':', |
|||
environment = {} |
|||
| ) |
Adds value(s) at the beginning of the list.
resolve references and duplications
Definition at line 95 of file Variable.py.
00095 :', environment={}): 00096 '''Adds value(s) at the beginning of the list.''' 00097 '''resolve references and duplications''' 00098 value = self.resolveReferences(value, environment, separator) 00099 00100 if type(value) is str: 00101 value = value.split(separator) 00102 00103 new_value = [] 00104 for v in value + self.val: 00105 if v not in new_value: 00106 new_value.append(v) 00107 else: 00108 self.report.addWarn('Var: "' + self.varName + '" value: "' + v + '". Addition canceled because of duplicate entry.') 00109 self.val = new_value 00110
| def EnvConfig::Variable::List::remove | ( | self, | |
| value, | |||
separator = ':', |
|||
regexp = False |
|||
| ) |
Removes value(s) from List. If value is not found, removal is canceled.
Definition at line 58 of file Variable.py.
00058 :', regexp=False): 00059 '''Removes value(s) from List. If value is not found, removal is canceled.''' 00060 if regexp: 00061 value = self.search(value, True) 00062 00063 elif isinstance(value,str): 00064 value = value.split(separator) 00065 00066 for i in range(len(value)): 00067 val = value[i] 00068 if val not in value: 00069 self.report.addWarn('Value "'+val+'" not found in List: "'+self.varName+'". Removal canceled.') 00070 while val in self.val: 00071 self.val.remove(val) 00072 00073
| def EnvConfig::Variable::List::remove_regexp | ( | self, | |
| value, | |||
separator = ':' |
|||
| ) |
Definition at line 55 of file Variable.py.
| def EnvConfig::Variable::List::repl | ( | self, | |
| s, | |||
| d | |||
| ) |
Definition at line 128 of file Variable.py.
| def EnvConfig::Variable::List::resolveReferences | ( | self, | |
| value, | |||
| environment, | |||
separator = ':' |
|||
| ) |
Resolves references to Lists
Definition at line 138 of file Variable.py.
00138 :'): 00139 '''Resolves references to Lists''' 00140 if isinstance(value, list): 00141 str = '' 00142 for val in value: 00143 str = val + '' + separator 00144 value = str[:len(str)-1] 00145 00146 value = self.repl(value, environment) 00147 value = value.split(separator) 00148 00149 value = self._remDuplicates(value) 00150 value = self._changeSlashes(value) 00151 return value 00152 00153
| def EnvConfig::Variable::List::search | ( | self, | |
| expr, | |||
| regExp | |||
| ) |
Searches in List`s values for a match
Use string value or set regExp to True.
In the first case search is done only for an exact match for one of List`s value ('^' and '$' added).
Definition at line 111 of file Variable.py.
00112 : 00113 '''Searches in List`s values for a match 00114 00115 Use string value or set regExp to True. 00116 In the first case search is done only for an exact match for one of List`s value ('^' and '$' added). 00117 ''' 00118 if not regExp: 00119 expr = '^' + expr + '$' 00120 v = re.compile(expr) 00121 res = [] 00122 for val in self.val: 00123 if v.search(val): 00124 res.append(val) 00125 00126 return res 00127
| def EnvConfig::Variable::List::set | ( | self, | |
| value, | |||
separator = ':', |
|||
environment = {}, |
|||
resolve = True |
|||
| ) |
Sets the value of the List. Any previous value is overwritten.
Definition at line 29 of file Variable.py.
00029 :', environment={}, resolve=True): 00030 '''Sets the value of the List. Any previous value is overwritten.''' 00031 if resolve: 00032 value = self.resolveReferences(value, environment, separator) 00033 else: 00034 value = value.split(separator) 00035 self.val = filter(None, value) 00036
| def EnvConfig::Variable::List::unset | ( | self, | |
| value, | |||
separator = ':', |
|||
environment = {} |
|||
| ) |
Sets the value of the List to empty. Any previous value is overwritten.
Definition at line 37 of file Variable.py.
| def EnvConfig::Variable::List::value | ( | self, | |
asString = False, |
|||
separator = ':' |
|||
| ) |
Returns values of the List. Either as a list or string with desired separator.
Definition at line 42 of file Variable.py.
00042 :'): 00043 '''Returns values of the List. Either as a list or string with desired separator.''' 00044 if asString: 00045 stri = self._concatenate(separator) 00046 return stri.replace(']', ':') 00047 else: 00048 lis = self.val[:] 00049 if platform.system() != 'Linux': 00050 for item in lis: 00051 item.replace(']',':') 00052 return lis 00053 00054
Definition at line 18 of file Variable.py.
Definition at line 18 of file Variable.py.
Definition at line 18 of file Variable.py.
Definition at line 18 of file Variable.py.