def processString(self, string, patterns): argumentMatch = patterns.argumentPattern.match(string) if not argumentMatch: return currBracketAnalyzer = BracketAnalyzer() arguments, _ = currBracketAnalyzer.getListOfArgumentsInOpenedBracketsAndRemainder(argumentMatch.group(1)) self.arguments = arguments
def getAccessorsAndRemainder(accessorString): symbolAccessString_match = RegExPatterns.Instance( ).symbolAccessPattern.match(accessorString) if not symbolAccessString_match: return [], accessorString currBracketAnalyzer = BracketAnalyzer() return currBracketAnalyzer.getListOfArgumentsInOpenedBracketsAndRemainder( symbolAccessString_match.group(1))
def setTemplateInfos(doc, parent, specText, templateParentNodeName, templateNodeName, referenceParentNodeName): if not parent: raise Exception("cannot add template info '%s' to nonexisting parent" % (specText)) templateLibrary = getOrCreateFirstLevelElement(doc, templateParentNodeName) templateNode = doc.createElement(templateNodeName) templateNode.setAttribute("id", str(uuid.uuid4())) settingPattern = re.compile(r'[\s,]*(\w*)\s*(\(.*)') remainder = specText while len(remainder) > 0: settingMatch = settingPattern.match(remainder) if not settingMatch: break name = settingMatch.group(1).strip() settingNode = doc.createElement(name) templateNode.appendChild(settingNode) textAfterSettingName = settingMatch.group(2) settingBracketAnalyzer = BracketAnalyzer() settingText, remainder = settingBracketAnalyzer.getTextWithinBracketsAndRemainder( textAfterSettingName) addAndGetEntries(doc, settingNode, settingText) #deduplicate the definition duplicateTemplateNode = firstDuplicateChild(templateLibrary, templateNode) if duplicateTemplateNode: templateNode = duplicateTemplateNode else: templateLibrary.appendChild(templateNode) if not hasattr(doc, "_templateCache"): doc._templateCache = {} templatesByID = doc._templateCache.get(templateNodeName, {}) templatesByID[templateNode.getAttribute("id")] = templateNode doc._templateCache[templateNodeName] = templatesByID templateID = templateNode.getAttribute("id") referenceParentNodes = parent.getElementsByTagName(referenceParentNodeName) referenceParentNode = None if len(referenceParentNodes) == 0: referenceParentNode = doc.createElement(referenceParentNodeName) parent.appendChild(referenceParentNode) else: referenceParentNode = referenceParentNodes[0] relationNode = doc.createElement("templateRelation") relationNode.setAttribute("id", templateID) referenceParentNode.appendChild(relationNode) return relationNode, templateNode
def setTemplateInfos(doc, parent, specText, templateParentNodeName, templateNodeName, referenceParentNodeName): if not parent: raise Exception("cannot add template info '%s' to nonexisting parent" %(specText)) templateLibrary = getOrCreateFirstLevelElement(doc, templateParentNodeName) templateNode = doc.createElement(templateNodeName) templateNode.setAttribute("id", str(uuid.uuid4())) settingPattern = re.compile(r'[\s,]*(\w*)\s*(\(.*)') remainder = specText while len(remainder) > 0: settingMatch = settingPattern.match(remainder) if not settingMatch: break name = settingMatch.group(1).strip() settingNode = doc.createElement(name) templateNode.appendChild(settingNode) textAfterSettingName = settingMatch.group(2) settingBracketAnalyzer = BracketAnalyzer() settingText, remainder = settingBracketAnalyzer.getTextWithinBracketsAndRemainder(textAfterSettingName) addAndGetEntries(doc, settingNode, settingText) #deduplicate the definition duplicateTemplateNode = firstDuplicateChild(templateLibrary, templateNode) if duplicateTemplateNode: templateNode = duplicateTemplateNode else: templateLibrary.appendChild(templateNode) if not hasattr(doc, "_templateCache"): doc._templateCache = {} templatesByID = doc._templateCache.get(templateNodeName, {}) templatesByID[templateNode.getAttribute("id")] = templateNode doc._templateCache[templateNodeName] = templatesByID templateID = templateNode.getAttribute("id") referenceParentNodes = parent.getElementsByTagName(referenceParentNodeName) referenceParentNode = None if len(referenceParentNodes) == 0: referenceParentNode = doc.createElement(referenceParentNodeName) parent.appendChild(referenceParentNode) else: referenceParentNode = referenceParentNodes[0] relationNode = doc.createElement("templateRelation") relationNode.setAttribute("id", templateID) referenceParentNode.appendChild(relationNode) return relationNode, templateNode
def getAccessorsAndRemainder(accessorString): symbolAccessString_match = RegExPatterns.Instance().symbolAccessPattern.match(accessorString) if not symbolAccessString_match: return [], accessorString currBracketAnalyzer = BracketAnalyzer() return currBracketAnalyzer.getListOfArgumentsInOpenedBracketsAndRemainder(symbolAccessString_match.group(1))