def is_ligolw(origin, filepath, fileobj, *args, **kwargs):
<EOL>if fileobj is not None:<EOL><INDENT>loc = fileobj.tell()<EOL>fileobj.seek(<NUM_LIT:0>)<EOL>try:<EOL><INDENT>line1 = fileobj.readline().lower()<EOL>line2 = fileobj.readline().lower()<EOL>try:<EOL><INDENT>return (line1.startswith(XML_SIGNATURE) and<EOL>line2.startswith((LIGOLW_SIGNATURE, LIGOLW_ELEMENT)))<EOL><DEDENT>except TypeError:  <EOL><INDENT>return (line1.startswith(XML_SIGNATURE.decode('<STR_LIT:utf-8>')) and<EOL>line2.startswith((LIGOLW_SIGNATURE.decode('<STR_LIT:utf-8>'),<EOL>LIGOLW_ELEMENT.decode('<STR_LIT:utf-8>'))))<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>fileobj.seek(loc)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>from ligo.lw.ligolw import Element<EOL><DEDENT>except ImportError:<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>from glue.ligolw.ligolw import Element as GlueElement<EOL><DEDENT>except ImportError:<EOL><INDENT>element_types = (Element,)<EOL><DEDENT>else:<EOL><INDENT>element_types = (Element, GlueElement)<EOL><DEDENT>return len(args) > <NUM_LIT:0> and isinstance(args[<NUM_LIT:0>], element_types)<EOL>
Identify a file object as LIGO_LW-format XML