Browse Source

there is no need to explicitly pass sys.argv to argparse... embarrassing

Von Random 11 months ago
parent
commit
43652ce5e4
2 changed files with 11 additions and 11 deletions
  1. 6
    6
      eyewatch.py
  2. 5
    5
      punycode.py

+ 6
- 6
eyewatch.py View File

@@ -18,22 +18,22 @@ MESSAGES = (
18 18
 )
19 19
 
20 20
 
21
-def parse_args(sys_args):
21
+def parse_args():
22 22
     desc = 'display a reminder to take a short break and do some eye practice'
23
-    p = ArgumentParser(description=desc)
24
-    p.add_argument(
23
+    parser = ArgumentParser(description=desc)
24
+    parser.add_argument(
25 25
         '-t',
26 26
         '--timer',
27 27
         default='600',
28 28
         help=('run in foreground, showing notification every TIMER seconds '
29 29
               '(this is default, with TIMER = 600)')
30 30
     )
31
-    p.add_argument(
31
+    parser.add_argument(
32 32
         '-i',
33 33
         '--icon',
34 34
         help='show ICON alongside the message'
35 35
     )
36
-    return p.parse_args(sys_args)
36
+    return parser.parse_args()
37 37
 
38 38
 
39 39
 def get_random_message(message_list):
@@ -49,7 +49,7 @@ def show_notification(notification, text=None, icon=None):
49 49
 
50 50
 
51 51
 def main():
52
-    args = parse_args(argv[1:])
52
+    args = parse_args()
53 53
     Notify.init(argv[0])
54 54
     notification = Notify.Notification.new(summary=TITLE)
55 55
 

+ 5
- 5
punycode.py View File

@@ -30,19 +30,19 @@ class Domain(object):
30 30
         if self.utf_8 is not None:
31 31
             print('UTF-8: \x1B[1m{}\x1B[0m'.format(self.utf_8))
32 32
 
33
-def parse_arguments(sysargs):
33
+def parse_arguments():
34 34
     """Parse and store arguments."""
35 35
     desc = 'A simple punycode to unicode and back converter.'
36
-    p = argparse.ArgumentParser(description=desc)
36
+    parser = argparse.ArgumentParser(description=desc)
37 37
 
38
-    p.add_argument('domain', help='domain name to convert')
38
+    parser.add_argument('domain', help='domain name to convert')
39 39
 
40 40
     # Store the supplied args
41
-    return p.parse_args(sysargs)
41
+    return parser.parse_args()
42 42
 
43 43
 
44 44
 def main(main_sysargs):
45
-    args = parse_arguments(main_sysargs[1:])
45
+    args = parse_arguments()
46 46
 
47 47
     domain = Domain(args.domain)
48 48
     domain.display()

Loading…
Cancel
Save