code: def with_read_ligolw(func=None, contenthandler=None):
      
      def decorator(func_):
          # pylint: disable=missing-docstring
          @wraps(func_)
          def decorated_func(source, *args, **kwargs):
              # pylint: disable=missing-docstring
              from ligo.lw.ligolw import Document
              from glue.ligolw.ligolw import Document as GlueDocument
              if not isinstance(source, (Document, GlueDocument)):
                  read_kw = {
                      'contenthandler': kwargs.pop('contenthandler',
                                                   contenthandler),
                      'verbose': kwargs.pop('verbose', False),
                  }
                  return func_(read_ligolw(source, **read_kw), *args, **kwargs)
              return func_(source, *args, **kwargs)
  
          return decorated_func
  
      if func is not None:
          return decorator(func)
      return decorator
docs: Decorate a LIGO_LW-reading function to open a filepath if needed
  
      ``func`` should be written to presume a
      :class:`~ligo.lw.ligolw.Document` as the first positional argument