there is no need to explicitly pass sys.argv to argparse... embarrassing
This commit is contained in:
parent
d16f5490bd
commit
43652ce5e4
2 changed files with 11 additions and 11 deletions
12
eyewatch.py
12
eyewatch.py
|
@ -18,22 +18,22 @@ MESSAGES = (
|
|||
)
|
||||
|
||||
|
||||
def parse_args(sys_args):
|
||||
def parse_args():
|
||||
desc = 'display a reminder to take a short break and do some eye practice'
|
||||
p = ArgumentParser(description=desc)
|
||||
p.add_argument(
|
||||
parser = ArgumentParser(description=desc)
|
||||
parser.add_argument(
|
||||
'-t',
|
||||
'--timer',
|
||||
default='600',
|
||||
help=('run in foreground, showing notification every TIMER seconds '
|
||||
'(this is default, with TIMER = 600)')
|
||||
)
|
||||
p.add_argument(
|
||||
parser.add_argument(
|
||||
'-i',
|
||||
'--icon',
|
||||
help='show ICON alongside the message'
|
||||
)
|
||||
return p.parse_args(sys_args)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def get_random_message(message_list):
|
||||
|
@ -49,7 +49,7 @@ def show_notification(notification, text=None, icon=None):
|
|||
|
||||
|
||||
def main():
|
||||
args = parse_args(argv[1:])
|
||||
args = parse_args()
|
||||
Notify.init(argv[0])
|
||||
notification = Notify.Notification.new(summary=TITLE)
|
||||
|
||||
|
|
10
punycode.py
10
punycode.py
|
@ -30,19 +30,19 @@ class Domain(object):
|
|||
if self.utf_8 is not None:
|
||||
print('UTF-8: \x1B[1m{}\x1B[0m'.format(self.utf_8))
|
||||
|
||||
def parse_arguments(sysargs):
|
||||
def parse_arguments():
|
||||
"""Parse and store arguments."""
|
||||
desc = 'A simple punycode to unicode and back converter.'
|
||||
p = argparse.ArgumentParser(description=desc)
|
||||
parser = argparse.ArgumentParser(description=desc)
|
||||
|
||||
p.add_argument('domain', help='domain name to convert')
|
||||
parser.add_argument('domain', help='domain name to convert')
|
||||
|
||||
# Store the supplied args
|
||||
return p.parse_args(sysargs)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main(main_sysargs):
|
||||
args = parse_arguments(main_sysargs[1:])
|
||||
args = parse_arguments()
|
||||
|
||||
domain = Domain(args.domain)
|
||||
domain.display()
|
||||
|
|
Loading…
Reference in a new issue