+def getCommentList(string):
+ commentList = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/", string)
+ commentList = [re.findall(r"^\s*\* *(.*?)$", comment, re.MULTILINE) for comment in commentList]
+ return commentList
+
+def loadModuleDefinition(first_comment):
+ toBeParsed = False
+ moduleDefinition = {}
+ for num, line in enumerate(first_comment):
+ index = line.find("$WIZ$")
+ if index != -1:
+ toBeParsed = True
+ try:
+ exec line[index + len("$WIZ$ "):] in {}, moduleDefinition
+ except:
+ raise ParseError(num, line[index:])
+ elif line.find("\\brief") != -1:
+ moduleDefinition["module_description"] = line[line.find("\\brief") + len("\\brief "):]
+ moduleDict = {}
+ if "module_name" in moduleDefinition.keys():
+ moduleDict[moduleDefinition["module_name"]] = {}
+ if "module_depends" in moduleDefinition.keys():
+ if type(moduleDefinition["module_depends"]) == str:
+ moduleDefinition["module_depends"] = (moduleDefinition["module_depends"],)
+ moduleDict[moduleDefinition["module_name"]]["depends"] = moduleDefinition["module_depends"]
+ else:
+ moduleDict[moduleDefinition["module_name"]]["depends"] = ()
+ if "module_configuration" in moduleDefinition.keys():
+ moduleDict[moduleDefinition["module_name"]]["configuration"] = moduleDefinition["module_configuration"]
+ else:
+ moduleDict[moduleDefinition["module_name"]]["configuration"] = ""
+ if "module_description" in moduleDefinition.keys():
+ moduleDict[moduleDefinition["module_name"]]["description"] = moduleDefinition["module_description"]
+ moduleDict[moduleDefinition["module_name"]]["enabled"] = False
+ return toBeParsed, moduleDict
+
+def loadDefineLists(commentList):
+ defineList = {}
+ for comment in commentList:
+ for num, line in enumerate(comment):
+ index = line.find("$WIZ$")
+ if index != -1:
+ try:
+ exec line[index + len("$WIZ$ "):] in {}, defineList
+ except:
+ raise ParseError(num, line[index:])
+ for key, value in defineList.items():
+ if type(value) == str:
+ defineList[key] = (value,)
+ return defineList
+
+def getDescriptionInformations(comment):
+ """
+ Take the doxygen comment and strip the wizard informations, returning the tuple
+ (comment, wizard_information)
+ """
+ brief = ""
+ description = ""
+ information = {}
+ for num, line in enumerate(comment):
+ index = line.find("$WIZ$")
+ if index != -1:
+ if len(brief) == 0:
+ brief += line[:index].strip()
+ else:
+ description += " " + line[:index]
+ try:
+ exec line[index + len("$WIZ$ "):] in {}, information
+ except:
+ raise ParseError(num, line[index:])
+ else:
+ if len(brief) == 0:
+ brief += line.strip()
+ else:
+ description += " " + line
+ description = description.strip()
+ return brief.strip(), description.strip(), information
+