diff --git a/Tests/iaas/flavor-naming/flavor-form.py b/Tests/iaas/flavor-naming/flavor-form.py
index 2324439e8..3061b4b6e 100755
--- a/Tests/iaas/flavor-naming/flavor-form.py
+++ b/Tests/iaas/flavor-naming/flavor-form.py
@@ -91,8 +91,9 @@ def generate_name(form):
if idx2 < 0:
ERROR = f"Can not find attribute {keypair[1]} in {keypair[1]}"
return None
- FLAVOR_SPEC[idx].parsed += 1
fdesc = FLAVOR_SPEC[idx].pnames[idx2]
+ if val and val != "" and val != "NN" and val != "0" and not (val == "1" and fdesc[0:2] == "#:"):
+ FLAVOR_SPEC[idx].parsed += 1
# Now parse fdesc to get the right value
if fdesc[0:2] == '##':
setattr(FLAVOR_SPEC[idx], keypair[1], float(val))
@@ -108,7 +109,12 @@ def generate_name(form):
if val == "NN":
val = ""
setattr(FLAVOR_SPEC[idx], keypair[1], val)
+ # Eliminate empty features
+ for spec in FLAVOR_SPEC:
+ if spec.pnames[0][0] == '.' and not getattr(spec, spec.pattrs[0]):
+ spec.parsed = 0
FLAVOR_NAME = fnmck.outname(*FLAVOR_SPEC)
+ print(*FLAVOR_SPEC, file=sys.stderr, sep='\n')
return FLAVOR_SPEC
@@ -178,7 +184,14 @@ def is_checked(flag):
return ""
-def form_attr(attr, tblopt = True):
+def keystr(key):
+ if key == "":
+ return "NN"
+ else:
+ return key
+
+
+def form_attr(attr):
"""This mirrors flavor-name-check.py input(), but instead generates a web form.
Defaults come from attr, the form is constructed from the attr's class
attributes (like the mentioned input function). tblopt indicates whether
@@ -206,19 +219,24 @@ def form_attr(attr, tblopt = True):
if hasattr(spec, f"tbl_{fname}"):
tbl = getattr(attr, f"tbl_{fname}")
if tbl:
- print(f'\t
')
+ tblopt = False
+ if fdesc[0] == '.':
+ tblopt = True
+ fdesc = fdesc[1:]
+ # print(f'\t
')
+ print(f'\t
')
value_set = False
for key in tbl.keys():
ischk = value == key
value_set = value_set or ischk
- print(f'\t ')
+ print(f'\t ')
print(f'\t
')
if tblopt:
print(f'\t ')
print(f'\t
')
elif fdesc[0:2] == "##":
# Float number => NUMBER
- print(f'\t
')
+ print(f'\t
')
print(f'\t ')
elif fdesc[0] == "#":
# Float number => NUMBER
@@ -229,12 +247,18 @@ def form_attr(attr, tblopt = True):
fdesc = fdesc[1:]
elif fdesc[1] == '.':
fdesc = fdesc[1:]
- print(f'\t
')
+ print(f'\t
')
print(f'\t ')
elif fdesc[0] == "?":
# Bool => Checkbox
print(f'\t ')
print(f'\t ')
+ else:
+ # FIXME: Handle dependent tables
+ if fdesc[0] == '.':
+ fdesc = fdesc[1:]
+ print(f'\t
')
+ print(f'\t ')
if fdesc[0] != "?" or i == len(spec.pnames)-1 or spec.pnames[i+1][0] != "?":
print('\t ')
else:
@@ -252,7 +276,7 @@ def output_generate():
print(f'\tERROR: {html.escape(ERROR, quote=True)}')
return
print('\t
\n\t