Changeset 9371c30 in mainline for tools/config.py
- Timestamp:
- 2005-12-06T20:53:03Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36e7b6c3
- Parents:
- 090e7ea1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config.py
r090e7ea1 r9371c30 187 187 188 188 def check_condition(text, defaults): 189 "Check that the condition specified on input line is True" 190 result = False 189 result = True 190 conds = text.split('&') 191 for cond in conds: 192 if cond.startswith('(') and cond.endswith(')'): 193 cond = cond[1:-1] 194 if not check_dnf(cond, defaults): 195 return False 196 return True 197 198 def check_dnf(text, defaults): 199 """ 200 Check that the condition specified on input line is True 201 202 only CNF is supported 203 """ 191 204 conds = text.split('|') 192 205 for cond in conds: 193 condname,condval = cond.split('=') 206 res = re.match(r'^(.*?)(!?=)(.*)$', cond) 207 if not res: 208 raise RuntimeError("Invalid condition: %s" % cond) 209 condname = res.group(1) 210 oper = res.group(2) 211 condval = res.group(3) 194 212 if not defaults.has_key(condname): 195 213 raise RuntimeError("Condition var %s does not exist: %s" % \ 196 (condname, line))197 # None means wildcard 198 if defaults[condname] is None:214 (condname,text)) 215 216 if oper=='=' and condval == defaults[condname]: 199 217 return True 200 if condval == defaults[condname]:218 if oper == '!=' and condval != defaults[condname]: 201 219 return True 202 220 return False … … 214 232 default = None 215 233 choices = [] 216 for line in f: 234 for line in f: 235 if line.startswith('%'): 236 res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line) 237 if not res: 238 raise RuntimeError('Invalid command: %s' % line) 239 if res.group(1): 240 if not check_condition(res.group(1), defaults): 241 continue 242 args = res.group(2).strip().split(' ') 243 cmd = args[0].lower() 244 args = args[1:] 245 if cmd == 'askdefault': 246 if isinstance(dlg, DefaultDialog): 247 continue 248 res = dlg.noyes('Change kernel configuration') 249 if res == 'n': 250 dlg = DefaultDialog(dlg) 251 elif cmd == 'saveas': 252 outf.write('%s = %s\n' % (args[1],defaults[args[0]])) 253 254 continue 255 217 256 if line.startswith('!'): 218 257 # Ask a question … … 229 268 if default is not None: 230 269 outf.write('#!# %s = %s\n' % (varname, default)) 270 # Clear cumulated values 271 comment = '' 272 default = None 273 choices = [] 231 274 continue 232 275 … … 278 321 279 322 def main(): 280 defaults = { 'ARCH':None}323 defaults = {} 281 324 try: 282 325 dlg = Dialog() … … 286 329 # Default run will update the configuration file 287 330 # with newest options 288 if len(sys.argv) >= 2: 289 defaults['ARCH'] = sys.argv[1] 290 if len(sys.argv) == 3 and sys.argv[2]=='default': 331 if len(sys.argv) == 2 and sys.argv[1]=='default': 291 332 dlg = DefaultDialog(dlg) 292 333
Note:
See TracChangeset
for help on using the changeset viewer.