def parse(something): try: if something.startswith('<?llsd/binary?>'): just_binary = something.split('\n', 1)[1] return LLSDBinaryParser().parse(just_binary) # This should be better. elif something.startswith('<'): return to_python(fromstring(something)[0]) else: return LLSDNotationParser().parse(something) except KeyError, e: raise Exception('LLSD could not be parsed: %s' % (e,))
def parse_xml(something): try: return to_python(fromstring(something)[0]) except ElementTreeError, err: raise LLSDParseError(*err.args)