def with_read_ligolw(func=None, contenthandler=None):
def decorator(func_):<EOL><INDENT>@wraps(func_)<EOL>def decorated_func(source, *args, **kwargs):<EOL><INDENT>from ligo.lw.ligolw import Document<EOL>from glue.ligolw.ligolw import Document as GlueDocument<EOL>if not isinstance(source, (Document, GlueDocument)):<EOL><INDENT>read_kw = {<EOL>'<STR_LIT>': kwargs.pop('<STR_LIT>',<EOL>contenthandler),<EOL>'<STR_LIT>': kwargs.pop('<STR_LIT>', False),<EOL>}<EOL>return func_(read_ligolw(source, **read_kw), *args, **kwargs)<EOL><DEDENT>return func_(source, *args, **kwargs)<EOL><DEDENT>return decorated_func<EOL><DEDENT>if func is not None:<EOL><INDENT>return decorator(func)<EOL><DEDENT>return decorator<EOL>
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