

def main():
    'Command-line wrapper to re-run a script whenever its source changes.\n\n    Scripts may be specified by filename or module name::\n\n        python -m tornado.autoreload -m tornado.test.runtests\n        python -m tornado.autoreload tornado/test/runtests.py\n\n    Running a script with this wrapper is similar to calling\n    `tornado.autoreload.wait` at the end of the script, but this wrapper\n    can catch import-time problems like syntax errors that would otherwise\n    prevent the script from reaching its call to `wait`.\n    '
    original_argv = sys.argv
    sys.argv = sys.argv[:]
    if ((len(sys.argv) >= 3) and (sys.argv[1] == '-m')):
        mode = 'module'
        module = sys.argv[2]
        del sys.argv[1:3]
    elif (len(sys.argv) >= 2):
        mode = 'script'
        script = sys.argv[1]
        sys.argv = sys.argv[1:]
    else:
        print(_USAGE, file=sys.stderr)
        sys.exit(1)
    try:
        if (f == 'module'):
            import runpy
            runpy.run_module(module, run_name='__main__', alter_sys=True)
        elif (mode == 'script'):
            with open(script) as f:
                global __file__
                __file__ = script
                exec_in(f.read(), globals(), globals())
    except SystemExit as e:
        logging.basicConfig()
        gen_log.info('Script exited with status %s', e.code)
    except Exception as e:
        logging.basicConfig()
        gen_log.warning('Script exited with uncaught exception', exc_info=True)
        for (filename, lineno, name, line) in traceback.extract_tb(sys.exc_info()[2]):
            watch(filename)
        if isinstance(e, SyntaxError):
            watch(e.filename)
    else:
        logging.basicConfig()
        gen_log.info('Script exited normally')
    sys.argv = original_argv
    if (mode == 'module'):
        loader = pkgutil.get_loader(module)
        if (loader is not None):
            watch(loader.get_filename())
    wait()

dataset/ETHPy150Open D-L/SimpleBookMarks/src/tornado/autoreload.py main/VarMisuse@148/359 `mode`->`f`