Load route rules
490341
private function loadRouteRules()
    {
        foreach ($this->rules['routeRules'] as $routeAlias => $routeRuleSets) {
            $resourceId = call_user_func_array($this->config['routeResourceGenerator'], [$routeAlias]);
            $this->acl->addResource(new Resource($resourceId));
            foreach ($routeRuleSets as $ruleSet) {
                $this->enforceRuleset($ruleSet, ['resources' => $resourceId, 'privileges' => $this->config['routePrivilege']]);
            }
        }
    }
4942
public function loadBundlesRoutes()
    {
        $loadedBundles = array_keys($this->container->findTaggedServiceIds('bundle.config'));
        foreach ($loadedBundles as $serviceId) {
            $config = $this->container->get($serviceId);
            $recipes = $this->getLoaderRecipesByConfig($config);

            $this->loadRoutes($config, $this->getCallbackFromRecipes($recipes, self::ROUTE_RECIPE_KEY));
        }
    }
650822
function loadRoutes() {
  try {
    var list = Crux.util.readDirectory(Component.appPath(this.config.path.routes), 'js'),
      self = this;
    if(list.length === 0) {
      return log.warn('Crux.server: component has no routes.');
    }
  } catch(e) {
    return;
  }

  list.forEach(function(routePath) {
    var routeObj = require(routePath);
    if(routeObj.skip === true) return;
    var httpRouteObj = self.createHttpRoute(routePath);
    if(!_.isFunction(routeObj)) {
      log.warn('Crux.server: Route %s does not export a function.', httpRouteObj.__rootPath);
      return;
    }
    routeObj(httpRouteObj);
    if(typeof self.routes[httpRouteObj.__namespace] !== 'undefined') {
      throw new Error("Route namespace " + httpRouteObj.__namespace + " previously registered.");
    }
    self.routes[httpRouteObj.__namespace] = httpRouteObj;
    routeCount++;
  });
  if(self.config.debug) {
    log.trace('Crux.server: %s route(s) loaded.', routeCount);
  }
}
393758
function RouteRule_createUrl(route, params) {
        var escape = [], i, len, c, url;

        if (this.route !== route) {
            if (!this.routeRule) {
                return false;
            }
            escape = this.match(this.routeRule, this.trim(route, '/'));
            if (!escape.length) {
                return false;
            }
            escape.forEach(function (item) {
                if (item.key.indexOf('<') === -1) {
                    item.key = '<' + item.key + '>';
                }
            });
        }

        len = this.paramRules.length;

        for (i = 0; i < len; ++i) {
            c = this.paramRules[i];
            if (params.hasOwnProperty(c.key) && (c.value === '' || (Type.isRegExp(c.value) && c.value.test(params[c.key])) || this.match(c.value, params[c.key].toString()).length > 0)) {
                escape.push({
                    key: '<' + c.key + '>',
                    value: params[c.key].toString()
                });
                delete params[c.key];
            } else if (Type.isUndefined(params[c.key])) {
                return false;
            }
        }

        url = this.trim(this.escape(this.template, escape), '/');

        if (this.match(this.pattern.regex, url).length === 0) {
            return false;
        }

        if (Object.keys(params).length > 0) {
            url += "?" + this.buildQuery(params);
        }
        return url;
    }
91446
def load(self, rule_type, quiet = False):
        
        if self.filename and os.path.exists(self.filename):
            try:
                with open(self.filename, 'rt') as f:
                    ruleset = json.load(f)
                    self.about = ruleset['about'] if 'about' in ruleset else ''
                    self.rules = {}
                    for filename in ruleset['rules']:
                        self.rules[filename] = []
                        for rule in ruleset['rules'][filename]:
                            self.handle_rule_versions(filename, rule_type, rule)
            except Exception as e:
                printException(e)
                printError('Error: ruleset file %s contains malformed JSON.' % self.filename)
                self.rules = []
                self.about = ''
        else:
            self.rules = []
            if not quiet:
                printError('Error: the file %s does not exist.' % self.filename)
1150521
public static function loadRules($options) {
		foreach (glob(__DIR__."/PatternData/Rules/*.php") as $filename) {
			$ruleName = str_replace(".php","",str_replace(__DIR__."/PatternData/Rules/","",$filename));
			if ($ruleName[0] != "_") {
				$ruleClass = "\PatternLab\PatternData\Rules\\".$ruleName;
				$rule      = new $ruleClass($options);
				self::setRule($ruleName, $rule);
			}
		}
	}
208470
def _parse_routes():
    '''
    
    '''
    with salt.utils.files.fopen('/proc/net/route', 'r') as fp_:
        out = salt.utils.stringutils.to_unicode(fp_.read())

    ret = {}
    for line in out.splitlines():
        tmp = {}
        if not line.strip():
            continue
        if line.startswith('Iface'):
            continue
        comps = line.split()
        tmp['iface'] = comps[0]
        tmp['destination'] = _hex_to_octets(comps[1])
        tmp['gateway'] = _hex_to_octets(comps[2])
        tmp['flags'] = _route_flags(int(comps[3]))
        tmp['refcnt'] = comps[4]
        tmp['use'] = comps[5]
        tmp['metric'] = comps[6]
        tmp['mask'] = _hex_to_octets(comps[7])
        tmp['mtu'] = comps[8]
        tmp['window'] = comps[9]
        tmp['irtt'] = comps[10]
        if comps[0] not in ret:
            ret[comps[0]] = []
        ret[comps[0]].append(tmp)
    return ret
899922
def load_rules(root='fmn.rules'):
    

    module = __import__(root, fromlist=[root.split('.')[0]])

    hinting_helpers = fmn.lib.hinting.__dict__.values()

    rules = {}
    for name in dir(module):
        obj = getattr(module, name)

        # Ignore non-callables.
        if not callable(obj):
            continue

        # Ignore our decorator and its friends
        if obj in hinting_helpers:
            continue

        doc = inspect.getdoc(obj)

        # It's crazy, but inspect (stdlib!) doesn't return unicode objs on py2.
        if doc and hasattr(doc, 'decode'):
            doc = doc.decode('utf-8')

        if doc:
            # If we have a docstring, then mark it up beautifully for display
            # in the web app.
            # FWIW, this should probably be moved into fmn.web since nowhere
            # else are we going to want HTML... we'll still want raw .rst.
            title, doc_as_rst = doc.split('\n', 1)
            doc = docutils.examples.html_parts(doc_as_rst)['body']
            soup = bs4.BeautifulSoup(doc, 'html5lib')
            doc_no_links = ''.join(map(six.text_type, strip_anchor_tags(soup)))
            doc = markupsafe.Markup(doc)
            doc_no_links = markupsafe.Markup(doc_no_links)
        else:
            title = "UNDOCUMENTED"
            doc = "No docs for %s:%s %r" % (root, name, obj)
            doc_no_links = doc

        rules[name] = {
            'func': obj,
            'submodule': obj.__module__.split('.')[-1],
            'title': title.strip(),
            'doc': doc.strip(),
            'doc-no-links': doc_no_links.strip(),
            'args': inspect.getargspec(obj)[0],
            'datanommer-hints': getattr(obj, 'hints', {}),
            'hints-invertible': getattr(obj, 'hinting_invertible', True),
            'hints-callable': getattr(obj, 'hinting_callable', None),
        }

    rules = OrderedDict(
        sorted(rules.items(), key=lambda x: x[1]['title'])
    )

    return {root: rules}
654899
protected function loadRoutes()
    {
        $builder = Router::createRouteBuilder('/');

        if ($this->app instanceof HttpApplicationInterface) {
            $this->app->routes($builder);
        }
        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->pluginRoutes($builder);
        }
    }
1277066
def _routes(self, app):
        
        _routes = []
        prefix = self.url_prefix if self.url_prefix is not None else ""
        for rule in app.url_map.iter_rules():
            if str(rule).startswith(prefix):
                _routes.append({
                    'path':rule.rule,
                    'name':rule.endpoint,
                    'methods':list(rule.methods)
                })
        returns = {
            'api': self.name,
            'url_root': request.url_root,
            'routes': _routes
        }
        return jsonify(returns)
1072899
def load_rule_definitions(self, ruleset_generator = False, rule_dirs = []):
        

        # Load rules from JSON files
        self.rule_definitions = {}
        for rule_filename in self.rules:
            for rule in self.rules[rule_filename]:
                if not rule.enabled and not ruleset_generator:
                    continue
            self.rule_definitions[os.path.basename(rule_filename)] = RuleDefinition(rule_filename, rule_dirs = rule_dirs)
        # In case of the ruleset generator, list all available built-in rules
        if ruleset_generator:
            rule_dirs.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/findings'))
            rule_filenames = []
            for rule_dir in rule_dirs:
                rule_filenames += [f for f in os.listdir(rule_dir) if os.path.isfile(os.path.join(rule_dir, f))]
            for rule_filename in rule_filenames:
                if rule_filename not in self.rule_definitions:
                    self.rule_definitions[os.path.basename(rule_filename)] = RuleDefinition(rule_filename)
845678
def load_rules(self):
        
        self.maps = []
        with open(self.map_file, 'r') as f:
            for line in f:
                if line.strip(' ')[0:1] != '#':
                    rule = MapRule(line)
                    #print('rule = ', rule)
                    self.maps.append(rule)
942581
function RouteRule(_routePath, handler, _routeName) {
        this._routePath = _routePath;
        this.handler = handler;
        this._routeName = _routeName;
        this._cache = new Map();
        this.specificity = this._routePath.specificity;
        this.hash = this._routePath.hash;
        this.terminal = this._routePath.terminal;
    }
1345989
protected function loadRoutes()
    {
        $path = $this->extensionPath;

        $routes = [
            'backend'  => [
                $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'backend.php',
                $path . DIRECTORY_SEPARATOR . 'backend.php',
                $path . DIRECTORY_SEPARATOR . 'routes.php',
            ],
            'frontend' => [
                $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'frontend.php',
                $path . DIRECTORY_SEPARATOR . 'frontend.php',
            ]
        ];
        foreach ($routes as $area => $routePaths) {
            foreach ($routePaths as $route) {
                if (!file_exists($route)) {
                    continue;
                }
                switch ($area) {
                    case 'frontend':
                        $this->loadFrontendRoutesFrom($route);
                        break;
                    case 'backend':
                        $this->loadBackendRoutesFrom($route);
                        break;
                }
            }
        }
    }
455933
function _rule_load($fpath) {
        if (!($fd = fopen($fpath, 'r'))) return false;
        $this->_rs = array();
        // quick scan to add the name to list
        $i = $j = 0;
        while ($buf = fgets($fd, 512)) {
            if (substr($buf, 0, 1) != '[' || !($pos = strpos($buf, ']')))
                continue;
            if ($pos == 1 || $pos > 15) continue;
            $key = strtolower(substr($buf, 1, $pos - 1));
            if (isset($this->_rs[$key])) continue;
            $item = array('tf' => 5.0, 'idf' => 3.5, 'attr' => 'un', 'bit' => 0, 'flag' => 0, 'zmin' => 0, 'zmax' => 0, 'inc' => 0, 'exc' => 0);
            if ($key == 'special') $item['bit'] = PSCWS4_RULE_SPECIAL;
            else if ($key == 'nostats') $item['bit'] = PSCWS4_RULE_NOSTATS;
            else {
                $item['bit'] = (1 << $j);
                $j++;
            }
            $this->_rs[$key] = $item;
            if (++$i >= PSCWS4_RULE_MAX)
                break;
        }
        // load the ruleset
        rewind($fd);
        $rbl = false;
        unset($item);
        while ($buf = fgets($fd, 512)) {
            $ch = substr($buf, 0, 1);
            if ($ch == ';') continue;
            if ($ch == '[') {
                unset($item);
                if (($pos = strpos($buf, ']')) > 1) {
                    $key = strtolower(substr($buf, 1, $pos - 1));
                    if (isset($this->_rs[$key])) {
                        $rbl = true;    // defalut read by line = yes
                        $item = &$this->_rs[$key];
                    }
                }
                continue;
            }
            // param set: line|znum|include|exclude|type|tf|idf|attr */
            if ($ch == ':') {
                $buf = substr($buf, 1);
                if (!($pos = strpos($buf, '='))) continue;
                list($pkey, $pval) = explode('=', $buf, 2);
                $pkey = trim($pkey);
                $pval = trim($pval);
                if ($pkey == 'line') $rbl = (strtolower(substr($pval, 0, 1)) == 'n' ? false : true);
                else if ($pkey == 'tf') $item['tf'] = floatval($pval);
                else if ($pkey == 'idf') $item['idf'] = floatval($pval);
                else if ($pkey == 'attr') $item['attr'] = $pval;    // 2bytes?
                else if ($pkey == 'znum') {
                    if ($pos = strpos($pval, ',')) {
                        $item['zmax'] = intval(trim(substr($pval, $pos + 1)));
                        $item['flag'] |= PSCWS4_ZRULE_RANGE;
                        $pval = substr($pval, 0, $pos);
                    }
                    $item['zmin'] = intval($pval);
                } else if ($pkey == 'type') {
                    if ($pval == 'prefix') $item['flag'] |= PSCWS4_ZRULE_PREFIX;
                    if ($pval == 'suffix') $item['flag'] |= PSCWS4_ZRULE_SUFFIX;
                } else if ($pkey == 'include' || $pkey == 'exclude') {
                    $clude = 0;
                    foreach (explode(',', $pval) as $tmp) {
                        $tmp = strtolower(trim($tmp));
                        if (!isset($this->_rs[$tmp])) continue;
                        $clude |= $this->_rs[$tmp]['bit'];
                    }
                    if ($pkey == 'include') {
                        $item['inc'] |= $clude;
                        $item['flag'] |= PSCWS4_ZRULE_INCLUDE;
                    } else {
                        $item['exc'] |= $clude;
                        $item['flag'] |= PSCWS4_ZRULE_EXCLUDE;
                    }
                }
                continue;
            }
            // read the entries
            if (!isset($item)) continue;
            $buf = trim($buf);
            if (empty($buf)) continue;
            // save the record
            if ($rbl) $this->_rd[$buf] = &$item;
            else {
                $len = strlen($buf);
                for ($off = 0; $off < $len;) {
                    $ord = ord(substr($buf, $off, 1));
                    $zlen = $this->_ztab[$ord];
                    if ($off + $zlen >= $len) break;
                    $zch = substr($buf, $off, $zlen);
                    $this->_rd[$zch] = &$item;
                    $off += $zlen;
                }
            }
        }
    }
818454
function Router_add(route) {
        var rule;
        if (Array.isArray(route)) {
            route.forEach(Router_add.bind(this));
            return;
        }
        if (route.dynamic) {
            if (Type.isFunction(route.constructor)) {
                rule = new route.constructor();
            } else {
                throw new error.HttpError(500, {route: route}, 'Router.add: dynamic route is not function');
            }
        } else {
            rule = new RouteRule(route);
        }

        if (!(rule instanceof RouteRuleInterface)) {
            throw new error.HttpError(500, {rule: rule, route: route}, 'Router.add: rule must be instance of RouteRuleInterface');
        }

        logger.info('Router.add:', route);

        this.routes.push(rule);
    }
948280
def _mount_resources(self):
        ''''''
        rules = []
        self.callback_map = {}
        for ep in Resource:
            for rule, callback in ep.get_routing_tuples():
                log.debug('Path "{}" mapped to "{}"'.format(
                    rule.rule, rule.endpoint))
                rules.append(rule)
                self.callback_map[rule.endpoint] = callback
        self.url_map = Map(rules)