Try to find the type of the parameter automatically if it isn't defined manually
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 24 Mar 2009 13:32:47 +0000 (13:32 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 24 Mar 2009 13:32:47 +0000 (13:32 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2412 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py

index 68483edc5bdf0d6885d240c6bc36c22ce0f1acb2..f4732edebfba4d295e23c4a984290134b6e25c57 100644 (file)
@@ -429,6 +429,7 @@ def loadConfigurationInfos(path):
             "min": the minimum value for integer parameters
             "max": the maximum value for integer parameters
             "long": boolean indicating if the num is a long
+            "unsigned": boolean indicating if the num is an unsigned
             "value_list": the name of the enum for enum parameters
     """
     configurationInfos = {}
@@ -438,6 +439,8 @@ def loadConfigurationInfos(path):
         configurationInfos[name] = {}
         configurationInfos[name]["value"] = value
         configurationInfos[name]["informations"] = informations
+        if not "type" in configurationInfos[name]["informations"]:
+            configurationInfos[name]["informations"]["type"] = findParameterType(configurationInfos[name])
         if ("type" in configurationInfos[name]["informations"].keys() and
                 configurationInfos[name]["informations"]["type"] == "int" and
                 configurationInfos[name]["value"].find("L") != -1):
@@ -452,6 +455,12 @@ def loadConfigurationInfos(path):
         configurationInfos[name]["brief"] = brief
     return configurationInfos
 
+def findParameterType(parameter):
+    if "value_list" in parameter["informations"]:
+        return "enum"
+    if "min" in parameter["informations"] or "max" in parameter["informations"] or re.match(r"^\d+U?L?$", parameter["value"]) != None:
+        return "int"
+
 def sub(string, parameter, value):
     """
     Substitute the given value at the given parameter define in the given string