equal
deleted
inserted
replaced
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
199 else: |
199 else: |
200 ask_confirm = True |
200 ask_confirm = True |
201 if not ask_confirm or self.confirm(msg): |
201 if not ask_confirm or self.confirm(msg): |
202 return meth(*args, **kwargs) |
202 return meth(*args, **kwargs) |
203 |
203 |
204 def confirm(self, question, shell=True, abort=True, retry=False, pdb=False, |
204 def confirm(self, question, # pylint: disable=E0202 |
205 default='y'): |
205 shell=True, abort=True, retry=False, pdb=False, default='y'): |
206 """ask for confirmation and return true on positive answer |
206 """ask for confirmation and return true on positive answer |
207 |
207 |
208 if `retry` is true the r[etry] answer may return 2 |
208 if `retry` is true the r[etry] answer may return 2 |
209 """ |
209 """ |
210 possibleanswers = ['y', 'n'] |
210 possibleanswers = ['y', 'n'] |
267 type "exit" or Ctrl-D to quit the shell and resume operation""" |
267 type "exit" or Ctrl-D to quit the shell and resume operation""" |
268 # give custom readfunc to avoid http://bugs.python.org/issue1288615 |
268 # give custom readfunc to avoid http://bugs.python.org/issue1288615 |
269 def unicode_raw_input(prompt): |
269 def unicode_raw_input(prompt): |
270 return unicode(raw_input(prompt), sys.stdin.encoding) |
270 return unicode(raw_input(prompt), sys.stdin.encoding) |
271 interact(banner, readfunc=unicode_raw_input, local=local_ctx) |
271 interact(banner, readfunc=unicode_raw_input, local=local_ctx) |
272 readline.write_history_file(histfile) |
272 try: |
|
273 readline.write_history_file(histfile) |
|
274 except IOError: |
|
275 pass |
273 # delete instance's confirm attribute to avoid questions |
276 # delete instance's confirm attribute to avoid questions |
274 del self.confirm |
277 del self.confirm |
275 self.need_wrap = True |
278 self.need_wrap = True |
276 |
279 |
277 @cached |
280 @cached |
409 toremove = (cube,) |
412 toremove = (cube,) |
410 origcubes = self.config._cubes |
413 origcubes = self.config._cubes |
411 basecubes = [c for c in origcubes if not c in toremove] |
414 basecubes = [c for c in origcubes if not c in toremove] |
412 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
415 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
413 removed = [p for p in origcubes if not p in self.config._cubes] |
416 removed = [p for p in origcubes if not p in self.config._cubes] |
414 if not cube in removed: |
417 if not cube in removed and cube in origcubes: |
415 raise ConfigurationError("can't remove cube %s, " |
418 raise ConfigurationError("can't remove cube %s, " |
416 "used as a dependency" % cube) |
419 "used as a dependency" % cube) |
417 return removed |
420 return removed |
418 |
421 |
419 def rewrite_configuration(self): |
422 def rewrite_configuration(self): |
486 self.reverse_dependencies.setdefault(name,set()) |
489 self.reverse_dependencies.setdefault(name,set()) |
487 if constraint: |
490 if constraint: |
488 try: |
491 try: |
489 oper, version = constraint.split() |
492 oper, version = constraint.split() |
490 self.reverse_dependencies[name].add( (oper, version, cube) ) |
493 self.reverse_dependencies[name].add( (oper, version, cube) ) |
491 except: |
494 except Exception: |
492 self.warnings.append( |
495 self.warnings.append( |
493 'cube %s depends on %s but constraint badly ' |
496 'cube %s depends on %s but constraint badly ' |
494 'formatted: %s' % (cube, name, constraint)) |
497 'formatted: %s' % (cube, name, constraint)) |
495 else: |
498 else: |
496 self.reverse_dependencies[name].add( (None, None, cube) ) |
499 self.reverse_dependencies[name].add( (None, None, cube) ) |