jenkins-bot submitted this change.
[IMPR] set -ignore option to CANCEL.MATCH by default
- set -ignore option to CANCEL.MATCH by default to ignore ISBN errors
- update module doc string
- simplify arg parsing
Bug: T108446
Change-Id: I0d7650d79262b38a512b360a0ff93069b35a5e00
---
M scripts/cosmetic_changes.py
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 5817188..dfc08e2 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -16,7 +16,12 @@
inserted.
-ignore: Ignores if an error occurred and either skips the page or
- only that method. It can be set to 'page' or 'method'.
+ only that method. It can be set to:
+ all - dos not ignore errors
+ match - ignores ISBN related errors (default)
+ method - ignores fixing method errors
+ page - ignores page related errors
+
The following generators and filters are supported:
@@ -59,7 +64,7 @@
self.available_options.update({
'async': False,
'summary': 'Robot: Cosmetic changes',
- 'ignore': CANCEL.ALL,
+ 'ignore': CANCEL.MATCH,
})
super().__init__(**kwargs)
@@ -91,23 +96,17 @@
gen_factory = pagegenerators.GeneratorFactory()
for arg in local_args:
- if arg.startswith('-summary:'):
- options['summary'] = arg[len('-summary:'):]
- elif arg == '-always':
- options['always'] = True
- elif arg == '-async':
- options['async'] = True
- elif arg.startswith('-ignore:'):
- ignore_mode = arg[len('-ignore:'):].lower()
- if ignore_mode == 'method':
- options['ignore'] = CANCEL.METHOD
- elif ignore_mode == 'page':
- options['ignore'] = CANCEL.PAGE
- elif ignore_mode == 'match':
- options['ignore'] = CANCEL.MATCH
- else:
- raise ValueError(
- 'Unknown ignore mode "{}"!'.format(ignore_mode))
+ opt, _, value = arg.partition(':')
+ if opt == '-summary':
+ options['summary'] = value
+ elif opt in ('-always', '-async'):
+ options[opt[1:]] = True
+ elif opt == '-ignore':
+ value = value.upper()
+ try:
+ options['ignore'] = getattr(CANCEL, value)
+ except AttributeError:
+ raise ValueError('Unknown ignore mode {!r}!'.format(value))
else:
gen_factory.handle_arg(arg)
To view, visit change 699486. To unsubscribe, or for help writing mail filters, visit settings.