Scanner¶
asciilint.scanner
¶
File discovery and scanning.
CharacterIssue
dataclass
¶
One disallowed character occurrence.
Discovery
dataclass
¶
File discovery result.
candidates_count counts file entries only. ignored_count counts
ignored file entries and each pruned directory once.
FileError
dataclass
¶
A file that could not be decoded or read.
FileFinding
dataclass
¶
Policy findings for one file.
truncated
property
¶
Return whether only a prefix of issues is stored.
IgnoreSource
dataclass
¶
Loaded ignore file and its compiled pathspec.
ScanResult
dataclass
¶
discover_files(paths, *, base_dir, respect_gitignore, ignore_files)
¶
Discover files while pruning gitignore-style directory matches.
is_text_file(path, *, sample_size=TEXT_SAMPLE_SIZE)
¶
Classify a file as text or binary with the zlib txtvsbin algorithm.
Files starting with a known binary format signature (BINARY_SIGNATURES)
are classified as binary before the byte-set check, since such formats can
consist entirely of allow-listed bytes.
Files up to 2 * sample_size bytes are read fully. Larger files are
sampled: sample_size bytes from the head and from the tail, so
classification cost is bounded regardless of file size.
relpath(path, base_dir)
¶
Return a stable POSIX-style path relative to base_dir when possible.
scan(paths, *, base_dir, respect_gitignore, ignore_files, policy, max_issues_per_file, on_discovery=None, on_status=None)
¶
Discover and scan text files.
scan_text_file(path, *, policy, max_issues_per_file, chunk_size=SCAN_CHUNK_SIZE)
¶
Scan one UTF-8 text file for policy violations.
The file is streamed in chunks of chunk_size decoded characters, so
memory stays bounded even for large files without line breaks. The policy
is evaluated once per distinct character in a chunk; chunks made entirely
of allowed characters skip the per-character position tracking.