def _run(filename=None, new_module=None, _larch=None):
    "execute the larch text in a file as larch code."
    if _larch is None:
        raise Warning("cannot run file '%s' -- larch broken?" % filename)

    text = None
    if isinstance(filename, file):
        text = filename.read()
        filename = filename.name
    elif os.path.exists(filename) and os.path.isfile(filename):
        try:
            text = open(filename).read()
        except IOError:
            _larch.writer.write("cannot read file '%s'\n" % filename)
            return
    else:
        _larch.writer.write("file not found '%s'\n" % filename)
        return

    return  _eval(text=text, filename=filename, _larch=_larch,
                  new_module=new_module, interactive=False, printall=False)
dataset/ETHPy150Open xraypy/xraylarch/lib/builtins.py/_run/original