From 44df8aae98d5ece40807ac4e167843a49d002d3f Mon Sep 17 00:00:00 2001
From: "Dennis.Glaeser" <dennis.glaeser@iws.uni-stuttgart.de>
Date: Tue, 3 Nov 2020 13:15:56 +0100
Subject: [PATCH] [bin][createparamlist] print multiple differing occurrences

This also changes the result as now the first default value that is not
None is chosen in the table. Thus, entries that were empty before might
now contain a default value. Also, we now use "-" instead of empty
colummns for parameters where no default value is specified anywhere in
the code.
---
 bin/doc/getparameterlist.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/bin/doc/getparameterlist.py b/bin/doc/getparameterlist.py
index 9a3509b4c4..300f4fb38d 100644
--- a/bin/doc/getparameterlist.py
+++ b/bin/doc/getparameterlist.py
@@ -125,9 +125,22 @@ for key in parameterDict:
     groupEntry = '-' if not hasGroup else entry['paramName'].split('.')[0]
     paramName = entry['paramName'] if not hasGroup else entry['paramName'].partition('.')[2]
 
-    # TODO: selection scheme in case of multiple occurrences? For now we use the first one
+    # In case of multiple occurrences, we use the first entry that is not None and print the others for possible manual editing
     paramType = entry['paramType'][0]
-    defaultValue = entry['defaultValue'][0] if entry['defaultValue'][0] != None else ''
+    defaultValue = next((e for e in entry['defaultValue'] if e), '-')
+
+    hasMultiplePT = True if not all(pt == paramType for pt in entry['paramType']) else False
+    hasMultipleDV = True if not all(dv == (defaultValue if defaultValue != '-' else None) for dv in entry['defaultValue']) else False
+    if hasMultiplePT or hasMultipleDV:
+        print('\nFound multiple occurrences of parameter ' + paramName + ' with differing specifications: ')
+    if hasMultiplePT:
+        print(' -> Specified type names:')
+        for typeName in entry['paramType']: print(' '*8 + typeName)
+        print(' ---> For the parameters list, ' + paramType + ' has been chosen. Please adapt manually if desired.')
+    if hasMultipleDV:
+        print(' -> Specified default values:')
+        for default in entry['defaultValue']: print(' '*8 + (default if default else '- (none given)'))
+        print(' ---> For the parameters list, ' + defaultValue + ' has been chosen. Please adapt manually if desired.')
 
     maxGroupWidth = max(maxGroupWidth, len(groupEntry)+3) # +3 because \b will be added later
     maxParamWidth = max(maxParamWidth, len(paramName))
-- 
GitLab