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:
|
||||
dst_node.set(name, x)
|
||||
|
||||
|
||||
def find_first_not_none(itr):
|
||||
for i in itr:
|
||||
if i is not None:
|
||||
return i
|
||||
return None
|
||||
|
||||
def find_attr(properties_attrs, name):
|
||||
for p_attr in properties_attrs:
|
||||
if p_attr is not None:
|
||||
p_attr = p_attr.find(name)
|
||||
if p_attr is not 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))
|
||||
|
||||
properties_attrs = list([p.get(property_name) for p in properties])
|
||||
description_docbook = find_first_not_none(
|
||||
p_attr.find("description-docbook")
|
||||
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
|
||||
)
|
||||
description_docbook = find_attr(properties_attrs, "description-docbook")
|
||||
description = find_attr(properties_attrs, "description")
|
||||
|
||||
if gl_only_from_first and properties_attrs[0] is None:
|
||||
dbg("> > > > skip (only-from-first")
|
||||
|
Reference in New Issue
Block a user