@@ -61,16 +61,16 @@ def output_parse():
61
61
62
62
def find_spec (lst , key ):
63
63
"Find index of class name key in lst, -1 means not found"
64
- for i in range ( 0 , len ( lst ) ):
65
- if type (lst [ i ] ).type == key :
64
+ for i , val in enumerate ( lst ):
65
+ if type (val ).type == key :
66
66
return i
67
67
return - 1
68
68
69
69
70
70
def find_attr (cls , key ):
71
71
"Find index of attribute in object cls, -1 means not found"
72
- for i in range ( 0 , len ( cls .pattrs ) ):
73
- if cls . pattrs [ i ] == key :
72
+ for i , val in enumerate ( cls .pattrs ):
73
+ if val == key :
74
74
return i
75
75
return - 1
76
76
@@ -104,7 +104,7 @@ def generate_name(form):
104
104
if fdesc [0 :2 ] == '##' :
105
105
setattr (spec , keypair [1 ], float (val ))
106
106
elif fdesc [0 ] == '#' :
107
- if fdesc [1 ] != '.' and not int (val ) > 0 :
107
+ if fdesc [1 ] != '.' and int (val ) <= 0 :
108
108
ERROR = f"ERROR: { key } must be > 0, found { val } "
109
109
return None
110
110
if fdesc [1 ] == ':' and not int (val ):
@@ -115,7 +115,7 @@ def generate_name(form):
115
115
elif hasattr (spec , f"tbl_{ keypair [1 ]} " ):
116
116
tbl = getattr (spec , f"tbl_{ keypair [1 ]} " )
117
117
# print(f'tbl_{keypair[1]}: {tbl}: Search for {val}', file=sys.stderr)
118
- if not val in tbl and (val or fdesc [0 ] != '.' ):
118
+ if val not in tbl and (val or fdesc [0 ] != '.' ):
119
119
ERROR = f'ERROR: Invalid key { val } for tbl_{ keypair [1 ]} '
120
120
return None
121
121
setattr (spec , keypair [1 ], val )
@@ -146,16 +146,14 @@ def is_checked(flag):
146
146
"Checked attribute string"
147
147
if flag :
148
148
return "checked"
149
- else :
150
- return ""
149
+ return ""
151
150
152
151
153
152
def keystr (key ):
154
153
"Empty string gets converted to NN"
155
154
if key == "" :
156
155
return "NN"
157
- else :
158
- return key
156
+ return key
159
157
160
158
161
159
def form_attr (attr ):
@@ -282,7 +280,7 @@ def main(argv):
282
280
print (f'QUERY_STRING: { os .environ ["QUERY_STRING" ]} ' , file = sys .stderr )
283
281
# For testing
284
282
if len (argv ) > 0 :
285
- form = {"flavor" : [argv [0 ],]}
283
+ form = {"flavor" : [argv [0 ], ]}
286
284
find_parse = re .compile (r'^[ \t]*<!\-\-FLAVOR\-FORM: PARSE\-\->[ \t]*$' )
287
285
find_generate = re .compile (r'^[ \t]*<!\-\-FLAVOR\-FORM: GENERATE\-\->[ \t]*$' )
288
286
if "flavor" in form :
0 commit comments