Skip to content

Commit c3adc67

Browse files
committed
Make flake8 happy and pylint happier.
Signed-off-by: Kurt Garloff <[email protected]>
1 parent 908b7fe commit c3adc67

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Tests/iaas/flavor-naming/flavor-form.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ def output_parse():
6161

6262
def find_spec(lst, key):
6363
"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:
6666
return i
6767
return -1
6868

6969

7070
def find_attr(cls, key):
7171
"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:
7474
return i
7575
return -1
7676

@@ -104,7 +104,7 @@ def generate_name(form):
104104
if fdesc[0:2] == '##':
105105
setattr(spec, keypair[1], float(val))
106106
elif fdesc[0] == '#':
107-
if fdesc[1] != '.' and not int(val) > 0:
107+
if fdesc[1] != '.' and int(val) <= 0:
108108
ERROR = f"ERROR: {key} must be > 0, found {val}"
109109
return None
110110
if fdesc[1] == ':' and not int(val):
@@ -115,7 +115,7 @@ def generate_name(form):
115115
elif hasattr(spec, f"tbl_{keypair[1]}"):
116116
tbl = getattr(spec, f"tbl_{keypair[1]}")
117117
# 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] != '.'):
119119
ERROR = f'ERROR: Invalid key {val} for tbl_{keypair[1]}'
120120
return None
121121
setattr(spec, keypair[1], val)
@@ -146,16 +146,14 @@ def is_checked(flag):
146146
"Checked attribute string"
147147
if flag:
148148
return "checked"
149-
else:
150-
return ""
149+
return ""
151150

152151

153152
def keystr(key):
154153
"Empty string gets converted to NN"
155154
if key == "":
156155
return "NN"
157-
else:
158-
return key
156+
return key
159157

160158

161159
def form_attr(attr):
@@ -282,7 +280,7 @@ def main(argv):
282280
print(f'QUERY_STRING: {os.environ["QUERY_STRING"]}', file=sys.stderr)
283281
# For testing
284282
if len(argv) > 0:
285-
form = {"flavor": [argv[0],]}
283+
form = {"flavor": [argv[0], ]}
286284
find_parse = re.compile(r'^[ \t]*<!\-\-FLAVOR\-FORM: PARSE\-\->[ \t]*$')
287285
find_generate = re.compile(r'^[ \t]*<!\-\-FLAVOR\-FORM: GENERATE\-\->[ \t]*$')
288286
if "flavor" in form:

0 commit comments

Comments
 (0)