generate-docs-nm-settings-docs-merge: streamline a bit
Replace a pair of overly sophisticated expressions with something that's easier to follow, avoiding code duplication at the same time.
This commit is contained in:
@@ -110,13 +110,12 @@ def node_set_attr(dst_node, name, nodes):
|
|||||||
if x:
|
if x:
|
||||||
dst_node.set(name, x)
|
dst_node.set(name, x)
|
||||||
|
|
||||||
|
def find_attr(properties_attrs, name):
|
||||||
def find_first_not_none(itr):
|
for p_attr in properties_attrs:
|
||||||
for i in itr:
|
if p_attr is not None:
|
||||||
if i is not None:
|
p_attr = p_attr.find(name)
|
||||||
return i
|
if p_attr is not None:
|
||||||
return None
|
return p_attr
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
@@ -180,17 +179,8 @@ for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name):
|
|||||||
dbg("> > > > property_name: %s" % (property_name))
|
dbg("> > > > property_name: %s" % (property_name))
|
||||||
|
|
||||||
properties_attrs = list([p.get(property_name) for p in properties])
|
properties_attrs = list([p.get(property_name) for p in properties])
|
||||||
description_docbook = find_first_not_none(
|
description_docbook = find_attr(properties_attrs, "description-docbook")
|
||||||
p_attr.find("description-docbook")
|
description = find_attr(properties_attrs, "description")
|
||||||
for p_attr in properties_attrs
|
|
||||||
if p_attr is not None
|
|
||||||
)
|
|
||||||
|
|
||||||
description = find_first_not_none(
|
|
||||||
p_attr.find("description")
|
|
||||||
for p_attr in properties_attrs
|
|
||||||
if p_attr is not None
|
|
||||||
)
|
|
||||||
|
|
||||||
if gl_only_from_first and properties_attrs[0] is None:
|
if gl_only_from_first and properties_attrs[0] is None:
|
||||||
dbg("> > > > skip (only-from-first")
|
dbg("> > > > skip (only-from-first")
|
||||||
|
Reference in New Issue
Block a user