File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change 11
11
from pprint import pprint
12
12
import sys
13
13
14
+
14
15
# --------------------------------------------------
15
16
def get_args ():
16
17
"""Get command-line arguments"""
@@ -33,7 +34,6 @@ def get_args():
33
34
nargs = "*" ,
34
35
default = None )
35
36
36
-
37
37
return parser .parse_args ()
38
38
39
39
@@ -57,23 +57,19 @@ def main():
57
57
58
58
match = re .findall ('(<([^<>]+)>)' , text )
59
59
60
- if len ( match ) == 0 :
60
+ if not match :
61
61
print (f'"{ pos_arg .name } " has no placeholders.' , file = sys .stderr )
62
62
sys .exit (1 )
63
63
64
-
65
- if not inputs :
66
- inputs = [input (f"Geef waarde voor { b } :" ) for a ,b in match ]
67
-
68
64
# print(inputs)
69
65
70
66
# pprint(match)
71
67
72
68
# print('text before:'+text)
73
- inputs . reverse ()
74
- for a , name in match :
75
- val = inputs .pop ()
76
- text = re .sub ('<[^<>]+>' , val , text , 1 )
69
+ for placeholder , name in match :
70
+ article = "a" if name [ 0 ]. lower () in 'aeoiu' else "an"
71
+ val = inputs .pop (0 ) if inputs else input ( "Give me {} {} " . format ( article , name ) )
72
+ text = re .sub (placeholder , val , text , 1 )
77
73
78
74
print (text )
79
75
You can’t perform that action at this time.
0 commit comments