Skip to content

v0.2.52..v0.2.53 changeset CreateConflationTypeGroups.py

Garret Voltz edited this page Feb 12, 2020 · 1 revision
diff --git a/scripts/services/CreateConflationTypeGroups.py b/scripts/services/CreateConflationTypeGroups.py
index f01a825..8682235 100644
--- a/scripts/services/CreateConflationTypeGroups.py
+++ b/scripts/services/CreateConflationTypeGroups.py
@@ -12,8 +12,8 @@ import re
 from collections import OrderedDict
 
 if (len(sys.argv) != 5):
-    print "Usage:"
-    print sys.argv[0] + " (UI Groups file) (Config Options file) (Group Defaults file) (output file)"
+    print("Usage:")
+    print(sys.argv[0] + " (UI Groups file) (Config Options file) (Group Defaults file) (output file)")
     sys.exit(-1)
 
 fn = sys.argv[1]
@@ -42,6 +42,14 @@ def toInput(optionType):
 def toLabel(conflateType):
     return 'Poi to Polygon' if conflateType == 'PoiPolygon' else conflateType;
 
+def getDefaultValue(templateKey):
+    defaultValueKey =  ''.join( c for c in templateKey if c not in '${}').replace('.', ' ').title().replace(' ', '')
+    defaultValue = configOptions[defaultValueKey]['default']
+    if '${' in defaultValue:
+        getDefaultValue(defaultValue)
+    else:
+        return defaultValue;
+
  # merges matches between ConfigOptions.json and conflationTypesMap.json
  # on command key back into conflationTypesMap. Outputs as ConflationTypesGroups.json
 def createUiJSON(groups, options):
@@ -64,9 +72,10 @@ def createUiJSON(groups, options):
                     })
                 else:
                     match = next(
-                        (m['key'] for m in configMembers if m['member']['key'] == flag), 
+                        (m['key'] for m in configMembers if m['member']['key'] == flag),
                         None
                     )
+
                     if match != None:
                         memberConfig = { 'label': typeMembers[flag], 'id': match }
                         memberConfig.update(configOptions[match])
@@ -75,9 +84,12 @@ def createUiJSON(groups, options):
                         if len(templateDefault) == 1:
                             defaultKey = templateDefault[0]
                             memberConfig['default'] = next(
-                                (m['member']['default'] for m in configMembers if m['member']['key'] == defaultKey),
-                                ''
+                            (m['member']['default'] for m in configMembers if m['member']['key'] == defaultKey),
+                            ''
                             )
+                            if '${' in memberConfig['default']:
+                                memberConfig['default'] = getDefaultValue(memberConfig['default'])
+
                         memberConfig['input'] = toInput(memberConfig['type'])
                         members.append(memberConfig)
 
Clone this wiki locally