def _makeTags(tagStr, xml):
if isinstance(tagStr,basestring):<EOL><INDENT>resname = tagStr<EOL>tagStr = Keyword(tagStr, caseless=not xml)<EOL><DEDENT>else:<EOL><INDENT>resname = tagStr.name<EOL><DEDENT>tagAttrName = Word(alphas,alphanums+"<STR_LIT>")<EOL>if (xml):<EOL><INDENT>tagAttrValue = dblQuotedString.copy().setParseAction( removeQuotes )<EOL>openTag = Suppress("<STR_LIT:<>") + tagStr("<STR_LIT>") +Dict(ZeroOrMore(Group( tagAttrName + Suppress("<STR_LIT:=>") + tagAttrValue ))) +Optional("<STR_LIT:/>",default=[False]).setResultsName("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>') + Suppress("<STR_LIT:>>")<EOL><DEDENT>else:<EOL><INDENT>printablesLessRAbrack = "<STR_LIT>".join(c for c in printables if c not in "<STR_LIT:>>")<EOL>tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printablesLessRAbrack)<EOL>openTag = Suppress("<STR_LIT:<>") + tagStr("<STR_LIT>") +Dict(ZeroOrMore(Group( tagAttrName.setParseAction(downcaseTokens) +Optional( Suppress("<STR_LIT:=>") + tagAttrValue ) ))) +Optional("<STR_LIT:/>",default=[False]).setResultsName("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>') + Suppress("<STR_LIT:>>")<EOL><DEDENT>closeTag = Combine(_L("<STR_LIT>") + tagStr + "<STR_LIT:>>")<EOL>openTag = openTag.setResultsName("<STR_LIT:start>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split())).setName("<STR_LIT>" % resname)<EOL>closeTag = closeTag.setResultsName("<STR_LIT:end>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split())).setName("<STR_LIT>" % resname)<EOL>openTag.tag = resname<EOL>closeTag.tag = resname<EOL>return openTag, closeTag<EOL>
Internal helper to construct opening and closing tag expressions, given a tag name