def configure(routes=None, filename=None, watch=False):

    def load_routes():
        newroutes = []
        f = open(filename)
        for line in f:
            parts = line.split()
            if len(parts) == 2:
                newroutes.append(map(split_host, parts))
            else:
                if parts:
                    print "Error, invalid route: %s" % line
        f.close()
        return newroutes

    if filename:
        routes = load_routes()
    elif routes:
        routes = [map(split_host, route) for route in routes]

    print "loaded %d routes" % len(routes)

    if watch and filename:
        from watchdog.observers import Observer
        from watchdog.events import PatternMatchingEventHandler

        class AliasWatcher(PatternMatchingEventHandler):
            def on_modified(self, event):
                routes[:] = load_routes()

        filename = os.path.normpath(os.path.abspath(filename))
        event_handler = AliasWatcher(patterns = [copy(filename)])
        observer = Observer()
        if not os.path.splitext(filename)[1]:
            filename = filename.rstrip('/') + '/'
        folder = os.path.split(filename)[0]
        observer.schedule(event_handler, path=folder, recursive=True)
        observer.start()

    return routes
dataset/ETHPy150Open braceio/localdev/localdev/server.py/configure/original