class
Analyzer::Python::Bottle
Defined in:
analyzer/analyzers/python/bottle.crConstant Summary
-
BARE_DECORATOR_PATTERNS =
BARE_DECORATORS.map do |deco_name| {deco_name, "@#{deco_name}", /^@#{deco_name}\([rf]?['"]([^'"]*)['"](.*)/, /@#{deco_name}\s*\(\s*[rf]?['"]([^'"]*)['"]/, /^\s*@#{deco_name}\s*\([^)]*\b(?:path|rule|uri)\s*=\s*[rf]?['"]([^'"]*)['"]/m} end -
Per-line matchers, hoisted so they compile once: an interpolated regex literal recompiles (PCRE2 JIT) on every evaluation, and the bare-decorator patterns ran per decorator name on every source line. The
.to_sexpansion is byte-identical to the previous inline form, so matching behaviour is unchanged. Tuple shape: {deco_name, "@deco" guard, bare_re, original_line_re, keyword_path_re} -
BARE_DECORATORS =
["route", "get", "post", "put", "delete", "patch", "head", "options"] of ::String -
BOTTLE_INSTANCE_RE =
/^(#{PYTHON_VAR_NAME_REGEX})(?::#{PYTHON_VAR_NAME_REGEX})?=(?:bottle\.)?Bottle\(/ -
DICT_ACCESSOR_PATTERNS =
DICT_ACCESSORS.map do |accessor, param_type| {param_type, /request\.#{accessor}\.get\s*\(\s*['"]([^'"]+)['"]/, /request\.#{accessor}\s*\[\s*['"]([^'"]+)['"]\s*\]/, /request\.#{accessor}\.([A-Za-z_][A-Za-z0-9_]*)\b/} end -
extract_request_paramsruns once per route and used to rebuild three PCRE2 patterns per accessor on every call. The accessor set is fixed, so precompile the access patterns once here. Tuple shape: {noir_param_type, get_re, bracket_re, attribute_re} -
DICT_ACCESSORS =
{"query" => "query", "forms" => "form", "json" => "json", "headers" => "header", "cookies" => "cookie"} -
Bottle attributes whose parameter type is independent of HTTP method. Maps the Python accessor name on
request.<name>to the noir param_type. -
DICT_METHOD_NAMES =
Set {"get", "getall", "getone", "items", "keys", "values", "pop"} -
Attribute names on accessor objects that are not user parameters.
-
MOUNT_RE =
/\b(#{PYTHON_VAR_NAME_REGEX})\.mount\s*\(\s*[rf]?['"]([^'"]*)['"]\s*,\s*(#{PYTHON_VAR_NAME_REGEX})/ -
PROGRAMMATIC_ROUTE_RE =
/\b(#{PYTHON_VAR_NAME_REGEX})\.route\s*\((.*)\)\s*$/m