add shorthand function for formatting
This commit is contained in:
parent
2e7d59ab43
commit
045f1d39a1
|
@ -254,6 +254,9 @@ class ConfigMaterial(Config):
|
||||||
Whether the material.yaml definition is complete.
|
Whether the material.yaml definition is complete.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
def LabeledList(label,items):
|
||||||
|
return f'{label.capitalize()}{"s" if len(items)>1 else ""} {util.srepr(items,",",quote=True)}'
|
||||||
|
|
||||||
ok = True
|
ok = True
|
||||||
msg = []
|
msg = []
|
||||||
all = set(['homogenization','phase','material'])
|
all = set(['homogenization','phase','material'])
|
||||||
|
@ -261,10 +264,10 @@ class ConfigMaterial(Config):
|
||||||
empty = set([item for item in all-miss if self[item] is None])
|
empty = set([item for item in all-miss if self[item] is None])
|
||||||
|
|
||||||
if miss:
|
if miss:
|
||||||
msg.append(f'Top-level{"s" if len(miss)>1 else ""} {util.srepr(miss,",",quote=True)} missing')
|
msg.append(f'{LabeledList("top-level",miss)} missing')
|
||||||
ok = False
|
ok = False
|
||||||
if empty:
|
if empty:
|
||||||
msg.append(f'Top-level{"s" if len(empty)>1 else ""} {util.srepr(empty,",",quote=True)} empty')
|
msg.append(f'{LabeledList("top-level",empty)} empty')
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
ok &= len(self['material']) > 0
|
ok &= len(self['material']) > 0
|
||||||
|
@ -294,11 +297,10 @@ class ConfigMaterial(Config):
|
||||||
'homogenization':homogenization}.items():
|
'homogenization':homogenization}.items():
|
||||||
me = set([] if v in empty else self[v])
|
me = set([] if v in empty else self[v])
|
||||||
if _miss := other - me:
|
if _miss := other - me:
|
||||||
msg.append(f'{v.capitalize()}{"s" if len(_miss)>1 else ""} {util.srepr(_miss,",",quote=True)} missing')
|
msg.append(f'{LabeledList(v,_miss)} missing')
|
||||||
ok = False
|
ok = False
|
||||||
_empty = [item for item in me if self[v][item] is None]
|
if len(_empty := [item for item in me if self[v][item] is None]) > 0:
|
||||||
if len(_empty) > 0:
|
msg.append(f'{LabeledList(v,_empty)} undefined')
|
||||||
msg.append(f'{v.capitalize()}{"s" if len(_empty)>1 else ""} {util.srepr(_empty,",",quote=True)} undefined')
|
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
print(util.srepr(msg))
|
print(util.srepr(msg))
|
||||||
|
|
Loading…
Reference in New Issue