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