- try:
- configurationInfos = {}
- for comment, define in newParser.getDefinitionBlocks(open(path, "r").read()):
- name, value = formatParamNameValue(define)
- description, informations = newParser.getDescriptionInformations(comment)
- configurationInfos[name] = {}
- configurationInfos[name]["value"] = value
- configurationInfos[name]["informations"] = informations
- if ("type" in configurationInfos[name]["informations"].keys() and
- configurationInfos[name]["informations"]["type"] == "int" and
- configurationInfos[name]["value"].find("L") != -1):
- configurationInfos[name]["informations"]["long"] = True
- configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
- if ("type" in configurationInfos[name]["informations"].keys() and
- configurationInfos[name]["informations"]["type"] == "int" and
- configurationInfos[name]["value"].find("U") != -1):
- configurationInfos[name]["informations"]["unsigned"] = True
- configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
- configurationInfos[name]["description"] = description
- return configurationInfos
- except newParser.ParseError, err:
- print "error in file %s. line: %d - statement %s" % (path, err.line_number, err.line)
- print err.args
- print err.message
- raise Exception
-
-def loadConfigurationInfos_old(path):
- """
- Return the module configurations found in the given file as a dict with the
- parameter name as key and a dict containig the fields above as value:
- "value": the value of the parameter
- "description": the description of the parameter
- "informations": a dict containig optional informations:
- "type": "int" | "boolean" | "enum"
- "min": the minimum value for integer parameters
- "max": the maximum value for integer parameters
- "long": boolean indicating if the num is a long
- "value_list": the name of the enum for enum parameters
- """
- try:
- configurationInfos = {}
- for comment, define in getDefinitionBlocks(open(path, "r").read()):
- name, value = formatParamNameValue(define)
- description, informations = getDescriptionInformations(comment)
- configurationInfos[name] = {}
- configurationInfos[name]["value"] = value
- configurationInfos[name]["informations"] = informations
- if ("type" in configurationInfos[name]["informations"].keys() and
- configurationInfos[name]["informations"]["type"] == "int" and
- configurationInfos[name]["value"].find("L") != -1):
- configurationInfos[name]["informations"]["long"] = True
- configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
- if ("type" in configurationInfos[name]["informations"].keys() and
- configurationInfos[name]["informations"]["type"] == "int" and
- configurationInfos[name]["value"].find("U") != -1):
- configurationInfos[name]["informations"]["unsigned"] = True
- configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
- configurationInfos[name]["description"] = description
- return configurationInfos
- except SyntaxError:
- raise DefineException.ConfigurationDefineException(path, name)
-
-def loadDefineLists(path):
- """
- Return a dict with the name of the list as key and a list of string as value
- """
- try:
- string = open(path, "r").read()
- commentList = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/", string)
- commentList = [" ".join(re.findall(r"^\s*\*?\s*(.*?)\s*?(?:/{2}.*?)?$", comment, re.MULTILINE)).strip() for comment in commentList]
- listDict = {}
- for comment in commentList:
- index = comment.find("$WIZARD_LIST")
- if index != -1:
- exec(comment[index + 1:])
- listDict.update(WIZARD_LIST)
- return listDict
- except SyntaxError:
- raise DefineException.EnumDefineException(path)
-
-def loadModuleInfos(path):
- """
- Returns the module infos and the lists infos founded in the file located in the path,
- and the configurations infos for the module defined in this file.
- """
- try:
- moduleInfos = {}
- listInfos = {}
- configurationsInfos = {}
- string = open(path, "r").read()
- commentList = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/", string)
- commentList = [" ".join(re.findall(r"^\s*\*?\s*(.*?)\s*?(?:/{2}.*?)?$", comment, re.MULTILINE)).strip() for comment in commentList]
- if len(commentList) > 0:
- comment = commentList[0]
- if comment.find("$WIZARD_MODULE") != -1:
- index = comment.find("$WIZARD_MODULE")
- if index != -1:
- # 14 is the length of "$WIZARD_MODULE"
- if len(comment[index + 14:].strip()) > 0:
- exec(comment[index + 1:])
- moduleInfos[WIZARD_MODULE["name"]] = {"depends": WIZARD_MODULE["depends"],
- "configuration": WIZARD_MODULE["configuration"],
- "description": "",
- "enabled": False}
- index = comment.find("\\brief")
- if index != -1:
- description = comment[index + 7:]
- description = description[:description.find(" * ")]
- moduleInfos[WIZARD_MODULE["name"]]["description"] = description
- if "configuration" in WIZARD_MODULE.keys() and len(WIZARD_MODULE["configuration"]) > 0:
- configurationsInfos[WIZARD_MODULE["configuration"]] = {}
- listInfos.update(loadDefineLists(path))
- return moduleInfos, listInfos, configurationsInfos
- except SyntaxError:
- raise DefineException.ModuleDefineException(path)
+ configurationInfos = {}
+ for comment, define in getDefinitionBlocks(open(path, "r").read()):
+ name, value = formatParamNameValue(define)
+ brief, description, informations = getDescriptionInformations(comment)
+ configurationInfos[name] = {}
+ configurationInfos[name]["value"] = value
+ configurationInfos[name]["informations"] = informations
+ if ("type" in configurationInfos[name]["informations"].keys() and
+ configurationInfos[name]["informations"]["type"] == "int" and
+ configurationInfos[name]["value"].find("L") != -1):
+ configurationInfos[name]["informations"]["long"] = True
+ configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
+ if ("type" in configurationInfos[name]["informations"].keys() and
+ configurationInfos[name]["informations"]["type"] == "int" and
+ configurationInfos[name]["value"].find("U") != -1):
+ configurationInfos[name]["informations"]["unsigned"] = True
+ configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
+ configurationInfos[name]["description"] = description
+ configurationInfos[name]["brief"] = brief
+ return configurationInfos