class

Analyzer::Python::Tornado

Inherits Analyzer::Python::PythonEngine < Analyzer < FileHelper < Reference < Object

Constants

APP_INSTANCE_RE = /(#{PYTHON_VAR_NAME_REGEX})(?::#{PYTHON_VAR_NAME_REGEX})?=(?:tornado\.web\.)?Application\(/

Per-line matchers that interpolate only constants — hoisted so the analyze loop doesn't recompile identical PCRE2 patterns on every source line. The .to_s expansion is byte-identical to the inline literals, so matching behaviour is unchanged.

CLASS_DEF_REGEX = /^class\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*[\(:]/
HANDLER_LIST_RE = /^(#{PYTHON_VAR_NAME_REGEX})(?::#{DOT_NATION})?=\[/
MODULE_PATTERN_CONST_RE = /^([A-Za-z_]\w*)\s*(?::\s*str\s*)?=\s*[rRuU]?(["'])(.*)\2\s*$/

_kernel_id_regex = r"(?P<kernel_id>...)" at module level.

OPTIONAL_GROUP_RE = /\(\?:[^()|]*\)\??/
PARAM_GROUP_RE = /\((?:\?P<\w+>)?(?!\?)[^()|]*\)/

What a route keeps as a path param for the regex-route test: a named or unnamed capture group (Tornado hands either to the handler), an optional non-capturing group around one, and a trailing /?. A group of alternatives ((robots\.txt|favicon\.ico)) is left, so it alone marks the route as a regex.

ROUTE_TUPLE_PARTIAL_RE = /\(\s*([rRfF]{0,2})(["'])(.*?)\2\s*(?:%\s*([A-Za-z_][\w.]*|\([^()]*\)))?\s*,\s*$/
ROUTE_TUPLE_RE = /\(\s*([rRfF]{0,2})(["'])(.*?)\2\s*(?:%\s*([A-Za-z_][\w.]*|\([^()]*\)))?\s*,\s*([^),]+)/

A route tuple's pattern: an r / f / rf literal, optionally formatted with % NAME or % (A, B) (Jupyter Server's r"/api/kernels/%s" % _kernel_id_regex).

ROUTE_TUPLE_TEXT_RE = /\(\s*([rRfF]{0,2})["']([^"']*)["']\s*(?:%\s*([A-Za-z_][\w.]*|\([^()]*\)))?\s*,\s*([a-zA-Z_][a-zA-Z0-9_.]*)/
TRAILING_OPTIONAL_SLASH = /\/\?\z/
URL_SPEC_TEXT_RE = /(?:^|[^a-zA-Z0-9_.])(?:tornado\.web\.)?(?:url|URLSpec)\s*\(\s*([rRfF]{0,2})["']([^"']*)["']\s*(?:%\s*([A-Za-z_][\w.]*|\([^()]*\)))?\s*,\s*([a-zA-Z_][a-zA-Z0-9_.]*)/

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source