def make_varname(tree):
if tree.tag == '<STR_LIT>':<EOL><INDENT>return tree.attrib['<STR_LIT:name>']<EOL><DEDENT>if tree.tag in ('<STR_LIT:string>', '<STR_LIT>'):<EOL><INDENT>return tree.text<EOL><DEDENT>if tree.tag == '<STR_LIT>':<EOL><INDENT>return tree.attrib['<STR_LIT:value>']<EOL><DEDENT>if tree.tag in ('<STR_LIT>', '<STR_LIT:object>'):<EOL><INDENT>return make_varname(_xpath_one(tree, '<STR_LIT:*>'))<EOL><DEDENT>if tree.tag.endswith('<STR_LIT>'):<EOL><INDENT>kind = tree.tag[:-len('<STR_LIT>')]<EOL>obj = make_varname(_xpath_one(tree, '<STR_LIT:object>'))<EOL>prop = make_varname(_xpath_one(tree, '<STR_LIT>'))<EOL>if kind == '<STR_LIT>':<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT>elif kind == '<STR_LIT>':<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % tree.tag)<EOL><DEDENT>return fmt % (obj, prop)<EOL><DEDENT>raise ValueError("<STR_LIT>" % tree.tag)<EOL>
<left> tree </left>