class
Analyzer::Python::Aiohttp
Defined in:
analyzer/analyzers/python/aiohttp.crConstant Summary
-
ADD_METHOD_ORIG_RE =
HTTP_METHOD_NAMES.to_h do |m| {m, /\.add_#{m}\s*\(\s*[rf]?['"]([^'"]*)['"]/} end -
Spaces are stripped before the
add_<method>match, so the route path is re-extracted from the original (spaced) line. Precompile one matcher per method name so the re-extraction isn't a per-route PCRE2 compile. Keyed by the same names captured by ADD_METHOD_RE. -
ADD_METHOD_RE =
/(#{DOT_NATION})\.add_(#{METHODS_ALT})\([rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/ -
ADD_ROUTE_ALIAS_RE =
/^(#{PYTHON_VAR_NAME_REGEX})\([rf]?['"]([A-Za-z*]+)['"]\s*,\s*[rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/ -
ADD_ROUTE_RE =
/(#{DOT_NATION})\.add_route\([rf]?['"]([A-Za-z*]+)['"]\s*,\s*[rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/ -
ADD_ROUTES_CALL_RE =
/(#{DOT_NATION})\.add_routes\s*\(/ -
ADD_ROUTES_VAR_RE =
/(#{DOT_NATION})\.add_routes\s*\(\s*(#{PYTHON_VAR_NAME_REGEX})/ -
ADD_STATIC_RE =
/(#{DOT_NATION})\.add_static\([rf]?['"]([^'"]*)['"]/ -
ADD_SUBAPP_RE =
/(#{DOT_NATION})\.add_subapp\s*\(\s*[rf]?['"]([^'"]*)['"]\s*,\s*(#{DOT_NATION})/ -
ADD_VIEW_RE =
/(#{DOT_NATION})\.add_view\([rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/ -
APP_PREFIX_RE =
/^(#{PYTHON_VAR_NAME_REGEX})(?::#{PYTHON_VAR_NAME_REGEX})?=(?:web\.)?Application\(/ -
Prefix-collection matchers.
collect_app_prefixes/collect_route_list_rangesscan every line of every file, so these were per-line PCRE2 recompiles before hoisting. -
DEF_METHOD_RE =
/^\s*(?:async\s+)?def\s+(#{METHODS_ALT})\s*\(/ -
DICT_ACCESSORS =
{"headers" => "header", "cookies" => "cookie"} -
DICT_METHOD_NAMES =
Set {"get", "getall", "getone", "items", "keys", "values", "pop"} -
HTTP_METHOD_NAMES =
["get", "post", "put", "delete", "patch", "head", "options"] of ::String -
LIST_ASSIGN_RE =
/^\s*(#{PYTHON_VAR_NAME_REGEX})\s*=\s*\[/ -
METHODS_ALT =
HTTP_METHOD_NAMES.join("|") -
The route-discovery patterns below interpolate only the PYTHON_VAR_NAME_REGEX/DOT_NATION constants and this fixed method alternation, so the inline literals were recompiling identical PCRE2 patterns on every source line of every file (and rebuilding
methods_rewith ajoineach line). Compile once here; the.to_sexpansion of the interpolated constants is byte-identical to the previous inline form, so matching behaviour is unchanged. -
ROUTE_ALIAS_RE =
/^(#{PYTHON_VAR_NAME_REGEX})=(#{DOT_NATION})\.add_route/ -
ROUTE_DECO_RE =
/@(#{PYTHON_VAR_NAME_REGEX})\.route\([rf]?['"]([A-Za-z*]+)['"]\s*,\s*[rf]?['"]([^'"]*)['"]/ -
WEB_METHOD_GUARD_RE =
/\bweb\.(?:#{METHODS_ALT})\s*\(/ -
WEB_METHOD_RE =
/\bweb\.(#{METHODS_ALT})\s*\(\s*[rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/ -
WEB_VIEW_RE =
/\bweb\.view\s*\(\s*[rf]?['"]([^'"]*)['"]\s*,\s*(?:handler\s*=\s*)?(#{DOT_NATION})/