code: def read_ligolw(source, contenthandler=LIGOLWContentHandler, **kwargs):
      
      from ligo.lw.ligolw import Document
      from ligo.lw import types
      from ligo.lw.lsctables import use_in
      from ligo.lw.utils import (load_url, ligolw_add)
  
      # mock ToPyType to link to numpy dtypes
      topytype = types.ToPyType.copy()
      for key in types.ToPyType:
          if key in types.ToNumPyType:
              types.ToPyType[key] = numpy.dtype(types.ToNumPyType[key]).type
  
      contenthandler = use_in(contenthandler)
  
      # read one or more files into a single Document
      source = file_list(source)
      try:
          if len(source) == 1:
              return load_url(
                  source[0],
                  contenthandler=contenthandler,
                  **kwargs
              )
          return ligolw_add.ligolw_add(
              Document(),
              source,
              contenthandler=contenthandler,
              **kwargs
          )
      except LigolwElementError as exc:
          # failed to read with ligo.lw,
          # try again with glue.ligolw (ilwdchar_compat)
          if LIGO_LW_COMPAT_ERROR.search(str(exc)):
              try:
                  return read_ligolw(
                      source,
                      contenthandler=contenthandler,
                      ilwdchar_compat=True,
                      **kwargs
                  )
              except Exception:  # if fails for any reason, use original error
                  pass
          raise
      finally:  # replace ToPyType
          types.ToPyType = topytype
docs: Read one or more LIGO_LW format files
  
      Parameters
      ----------
      source : `str`, `file`
          the open file or file path to read
  
      contenthandler : `~xml.sax.handler.ContentHandler`, optional
          content handler used to parse document
  
      verbose : `bool`, optional
          be verbose when reading files, default: `False`
  
      Returns
      -------
      xmldoc : :class:`~ligo.lw.ligolw.Document`
          the document object as parsed from the file(s)