create a router str -> obj
764047
function Wayfarer (dft) {
  if (!(this instanceof Wayfarer)) return new Wayfarer(dft)

  var _default = (dft || '').replace(/^\//, '')
  var _trie = trie()

  emit._trie = _trie
  emit.on = on
  emit.emit = emit
  emit.match = match
  emit._wayfarer = true

  return emit

  // define a route
  // (str, fn) -> obj
  function on (route, fn) {
    assert.equal(typeof route, 'string')
    assert.equal(typeof fn, 'function')

    var cb = fn._wayfarer && fn._trie ? fn : proxy
    route = route || '/'
    cb.route = route

    if (cb._wayfarer && cb._trie) {
      _trie.mount(route, cb._trie.trie)
    } else {
      var node = _trie.create(route)
      node.cb = cb
    }

    return emit

    function proxy () {
      return fn.apply(this, Array.prototype.slice.call(arguments))
    }
  }

  // match and call a route
  // (str, obj?) -> null
  function emit (route) {
    var matched = match(route)

    var args = new Array(arguments.length)
    args[0] = matched.params
    for (var i = 1; i < args.length; i++) {
      args[i] = arguments[i]
    }

    return matched.cb.apply(matched.cb, args)
  }

  function match (route) {
    assert.notEqual(route, undefined, "'route' must be defined")

    var matched = _trie.match(route)
    if (matched && matched.cb) return new Route(matched)

    var dft = _trie.match(_default)
    if (dft && dft.cb) return new Route(dft)

    throw new Error("route '" + route + "' did not match")
  }

  function Route (matched) {
    this.cb = matched.cb
    this.route = matched.cb.route
    this.params = matched.params
  }
}
226351
def __convertRlocToRouterId(self, xRloc16):
        
        routerList = []
        routerList = self.__sendCommand('router list')[0].split()
        print routerList
        print xRloc16

        for index in routerList:
            router = []
            cmd = 'router %s' % index
            router = self.__sendCommand(cmd)

            for line in router:
                if 'Done' in line:
                    break
                elif 'Router ID' in line:
                    routerid = line.split()[2]
                elif 'Rloc' in line:
                    rloc16 = line.split()[1]
                else:
                    pass

            # process input rloc16
            if isinstance(xRloc16, str):
                rloc16 = '0x' + rloc16
                if rloc16 == xRloc16:
                    return routerid
            elif isinstance(xRloc16, int):
                if int(rloc16, 16) == xRloc16:
                    return routerid
            else:
                pass

        return None
563145
function createRouterDispatcher({
    runtimeRouters,
    reqQuery,
    reqMethod,
    reqPath,
    viewRoot,
    extension,
    syncDataMatch,
    asyncDataMatch
}) {
    if (Number(reqQuery.mode) === 1) {
        return;
    }

    let dispatcher;
    const routers = values(runtimeRouters).reduce(
        (prev, item) => prev.concat(item),
        []
    );
    routers.some(function(router) {
        const { filePath, method, sync, url, handler } = router;

        const METHODS = ['GET', 'POST', 'PUT', 'DELETE'];
        const upperMethod = method && method.toUpperCase() || '';
        const notMatchMethod = upperMethod && METHODS.includes(upperMethod) && upperMethod !== reqMethod;

        if (!reqPath.match(pathToRegexp(url)) || notMatchMethod) {
            return false;
        }

        dispatcher = {
            router,
            filePath,
            handler
        };

        if (sync) {
            const tplName = removeSuffix(filePath, extension);
            return Object.assign(dispatcher, {
                type: 'sync',
                pagePath: path.join(viewRoot, `${tplName}.${extension}`),
                dataPath: syncDataMatch(ensureJSONExtension(tplName))
            });
        }

        return Object.assign(dispatcher, {
            type: 'async',
            dataPath: asyncDataMatch(ensureJSONExtension(filePath))
        });
    });

    return dispatcher;
}
1226847
def object(path, api: ApiOptions::A0)
      node = get_node(path, _create = true)
      if node.object.nil? || node.object.api != api
        node.object = ProxyObject.new(
          @bus, @name, path,
          api: api
        )
      end
      node.object
    end
1319873
function GhostRouter(options) {
    const router = express.Router(options);

    function innerRouter(req, res, next) {
        return innerRouter.handle(req, res, next);
    }

    Object.setPrototypeOf(innerRouter, router);

    Object.defineProperty(innerRouter, 'name', {
        value: options.parent.name,
        writable: false
    });

    innerRouter.parent = options.parent;
    return innerRouter;
}
1343525
def add_route(self, router, index=None):
        '''
        '''
        assert isinstance(router, Router), 'Not a valid Router'
        assert router is not self, 'cannot add self to children'

        for r in self.routes:
            if r == router:
                return r
            elif r._route == router._route:
                raise ValueError('Cannot add route %s. Already avalable' %
                                 r._route)
        #
        # Remove from previous parent
        if router.parent:
            router.parent.remove_child(router)
        router._parent = self
        if index is None:
            self.routes.append(router)
        else:
            self.routes.insert(index, router)
        return router
733845
def show_router(self, router, **_params):
        """"""
        return self.get(self.router_path % (router), params=_params)
1280811
function attachRoutes(router, routes = [], site) {
  routes.forEach((route) => {
    parseHandler(router, route, site);
  });

  return router;
}
1016994
def serialize(self, f):
        
        s = self.router()

        @self.spawn
        def _():
            for f, a, kw, r in s.recver:
                try:
                    r.send(f(*a, **kw))
                except Exception, e:
                    r.send(e)

        def _(*a, **kw):
            r = self.pipe()
            s.send((f, a, kw, r))
            return r.recv()

        return _
932865
function createRouter(ClonedVue) {
    var routes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

    var VueRouter = require('vue-router');

    if (typeof VueRouter.default === 'function') {
        VueRouter = VueRouter.default;
    }

    ClonedVue.use(VueRouter);

    var normalizedRoutes = routes.map(function (route) {
        return typeof route === 'string' ? stubRoute(route) : route;
    });

    return new VueRouter({
        mode: 'abstract',
        routes: normalizedRoutes
    });
}
1324269
def create(cls, parent=None, **kwargs):
        """"""

        if parent is None:
            raise Exception("Parent class is required")

        route = copy(parent.route)
        if cls.ID_NAME is not None:
            route[cls.ID_NAME] = ""

        obj = cls(key=parent.key, route=route, config=parent.config)

        start = datetime.now()
        response = requests.post(obj._url(), auth=(obj.key, ""), data=kwargs)
        cls._delay_for_ratelimits(start)

        if response.status_code not in cls.TRUTHY_CODES:
            return cls._handle_request_exception(response)

        # No envelope on post requests
        data = response.json()
        obj.route[obj.ID_NAME] = data.get("id", data.get(obj.ID_NAME))
        obj.data = data

        return obj
1217376
function Router() {

  // Routes with all verbs
  var routes = {};
  methods.forEach(function (method) {
    routes[method] = [];
  });

  this.routes = routes;
  this.commonHandlers = [];
  this.routers = [];
}
307607
def exempt(self, obj):
        
        name = '%s.%s' % (obj.__module__, obj.__name__)

        @wraps(obj)
        def __inner(*a, **k):
            return obj(*a, **k)

        self._exempt_routes.add(name)
        return __inner
334429
function FrameworkRouter(framework) {
  debug('create framework router');

  this.framework = framework;
  this.encoder = lodash.clone(http.encoder);
  this.decoder = lodash.clone(http.decoder);
}
556828
function obj(argv, callback) {
  var uri = argv[2];

  if (argv[3]) {
    util.put(argv[2], '<> <> """' + argv[3] + '""" .', function(err, callback){
      if (err) {
        console.error(err);
      } else {
        console.log('put value : ' + argv[3]);
      }
    });
  } else {
    var wss = 'wss://' + uri.split('/')[2] + '/';

    var s = new ws(wss, {
      origin: 'http://websocket.org'
    });

    s.on('open', function open() {
      s.send('sub ' + uri);
    });

    s.on('close', function close() {
      console.log('disconnected');
    });

    s.on('message', function message(data, flags) {
      var a = data.split(' ');
      if (a.length && a[0] === 'pub') {
        util.getAll(a[1], function(err, res) {
          if (err) {
            callback(err);
          } else {
            callback(null, res[res.length-1].object.value);
          }
        });
      }
    });
  }
}
54149
def create_router(self, name, tenant_id, subnet_lst):
        
        try:
            body = {'router': {'name': name, 'tenant_id': tenant_id,
                               'admin_state_up': True}}
            router = self.neutronclient.create_router(body=body)
            rout_dict = router.get('router')
            rout_id = rout_dict.get('id')
        except Exception as exc:
            LOG.error("Failed to create router with name %(name)s"
                      " Exc %(exc)s", {'name': name, 'exc': str(exc)})
            return None

        ret = self.add_intf_router(rout_id, tenant_id, subnet_lst)
        if not ret:
            try:
                ret = self.neutronclient.delete_router(rout_id)
            except Exception as exc:
                LOG.error("Failed to delete router %(name)s, Exc %(exc)s",
                          {'name': name, 'exc': str(exc)})
            return None
        return rout_id
1204791
def create(name, database=None, auto=False, auto_source=False, directory=None, verbose=None):
    """"""
    router = get_router(directory, database, verbose)
    if auto and auto_source:
        auto = auto_source
    router.create(name, auto=auto)