Limit argument range for --verbose, make default log level more explicit. #93
|
@ -92,6 +92,8 @@ def parse_arguments(*arguments):
|
|||
parser.add_argument(
|
||||
'-v', '--verbosity',
|
||||
type=int,
|
||||
choices=range(0,3),
|
||||
|
||||
default=0,
|
||||
help='Display verbose progress (1 for some, 2 for lots)',
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
|
|||
|
||||
assert parser.config_paths == config_paths
|
||||
assert parser.excludes_filename == None
|
||||
assert parser.verbosity is None
|
||||
assert parser.verbosity is 0
|
||||
assert parser.json is False
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ def test_parse_arguments_with_path_arguments_overrides_defaults():
|
|||
|
||||
assert parser.config_paths == ['myconfig']
|
||||
assert parser.excludes_filename == 'myexcludes'
|
||||
assert parser.verbosity is None
|
||||
assert parser.verbosity is 0
|
||||
|
||||
|
||||
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
||||
|
@ -34,7 +34,7 @@ def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
|||
parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
|
||||
|
||||
assert parser.config_paths == ['myconfig', 'otherconfig']
|
||||
assert parser.verbosity is None
|
||||
assert parser.verbosity is 0
|
||||
|
||||
|
||||
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
|
||||
|
||||
VERBOSITY_WARNING = 0
|
||||
VERBOSITY_SOME = 1
|
||||
VERBOSITY_LOTS = 2
|
||||
witten
commented
Minor code style thing: I generally try to avoid manually lining up operators like this across lines with spacing. So I think I'd prefer this alterative if you don't mind:
Minor code style thing: I generally try to avoid manually lining up operators like this across lines with spacing. So I think I'd prefer this alterative if you don't mind:
```
VERBOSITY_WARNING = 0
VERBOSITY_SOME = 1
VERBOSITY_LOTS = 2
```
witten
commented
I'm inspired by PEP-8 on this topic, by the way: https://www.python.org/dev/peps/pep-0008/#pet-peeves (scroll down to the last example in that section). I'm inspired by PEP-8 on this topic, by the way: [https://www.python.org/dev/peps/pep-0008/#pet-peeves](https://www.python.org/dev/peps/pep-0008/#pet-peeves) (scroll down to the last example in that section).
|
||||
|
||||
|
@ -10,6 +11,7 @@ def verbosity_to_log_level(verbosity):
|
|||
Given a borgmatic verbosity value, return the corresponding Python log level.
|
||||
'''
|
||||
return {
|
||||
VERBOSITY_WARNING: logging.WARNING,
|
||||
VERBOSITY_SOME: logging.INFO,
|
||||
VERBOSITY_LOTS: logging.DEBUG,
|
||||
}.get(verbosity, logging.WARNING)
|
||||
|
|
Loading…
Reference in New Issue
At first I forgot that the end of
range()
is non-inclusive, and thought you were adding a new super-debug log level. But then I figured it out. :)