|
Option C Tools
|
Functions | |
| list[str] | _scan_content_for_secrets (str content, str rel_path) |
| list[str] | _get_cached_secret_warnings (str abs_path, str content, str rel_path) |
| dict | load_exporter_config (Path root) |
| bool | should_skip_dirname (str dirname, dict cfg) |
| bool | _is_never_export_file (str filename) |
| List[Path] | collect_recursive_files (Path folder, dict cfg) |
| Tuple[int, int, int] | get_file_stats (Path path) |
| walk_included_dirs (Path start, dict cfg) | |
| None | clean_source_dirs (Path root, bool dry_run=False) |
| None | clean_pycache_dirs (Path root, bool dry_run=False) |
| Path | _make_safe_output_path (Path out_dir, str dotpath, dict cfg, str prefix="_source") |
| write_source_file_for_dir (Path folder, Path output_path, Path root, dict cfg, bool warn_secrets=False, bool block_secrets=False, set[Path]|None diff_filter=None) | |
| None | run_exporter (Path root, list[str] args) |
Variables | |
| _SECRET_ASSIGN_RE | |
| dict | _secret_scan_cache = {} |
| set | _scanned_secret_paths = set() |
| dict | _EXTENSION_PROFILES |
| list | INCLUDE_EXTENSIONS = [ext for exts in _EXTENSION_PROFILES.values() for ext in exts] |
| tuple | HEADER_TEXT |
| str | SEPARATOR_FILE = "##### File name {num:02d}: {path}\n" |
| str | SEPARATOR_SUBDIR = "####### Subdirectory name {num:02d}: {dirname}\n" |
| str | ROOT_HEADER = "####### Root directory: .\n\n" |
| int | _MAX_SAFE_PATH_LEN = 240 |
| str | _CONFIG_FILENAME = "_oct_exporter_config.json" |
Purpose
-------
Provide a unified, Option C‑compliant source‑exporting tool that collects,
combines, and consolidates all source‑code files in a project into structured
inspection files. This enables fast review, debugging, auditing, and
cross‑project comparison.
Responsibilities
----------------
- Walk a project directory tree while respecting exclusion rules.
- Collect all source files with supported extensions.
- Generate per‑directory `_source.<path>.txt` files.
- Generate a root‑level `_full_source.<root>.txt` file.
- Support `--clean` to remove all `_source_code-*` directories.
- Support `--verbose` to print per‑file statistics.
- Integrate cleanly with the OCT CLI as `oct export-source`.
- Handle I/O errors (including Windows MAX_PATH) gracefully: warn and continue.
Diagnostics
-----------
Domain: OCT-EXPORTER
Levels:
L2 — lifecycle
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Must not modify project files except inside `_source_code-*` directories.
- Must accept any directory as a valid export root.
- Must remain deterministic and safe for large projects.
- Must not require external dependencies beyond the standard library.
- Must never crash on a recoverable I/O error; warn and continue instead.
|
protected |
Return (cached or computed) secret warnings for ``abs_path``.
Definition at line 100 of file source_exporter.py.
|
protected |
Check if a file matches NEVER_EXPORT_FILE_PATTERNS (§6b Secret Hygiene).
Definition at line 249 of file source_exporter.py.
|
protected |
Build the output file path, truncating the dotpath if the full path would exceed the Windows MAX_PATH limit (~260 chars). A short MD5 hash suffix is appended when truncation is applied to ensure uniqueness.
Definition at line 336 of file source_exporter.py.
|
protected |
Scan ``content`` for likely hardcoded secrets. Returns warning strings. Uses the same name-heuristics as the linter (``_SECRET_NAME_PATTERNS``). Empty list means no warnings. The ``rel_path`` is embedded in each warning for user attribution.
Definition at line 66 of file source_exporter.py.
| None source_exporter.clean_pycache_dirs | ( | Path | root, |
| bool | dry_run = False ) |
Remove all __pycache__ directories under root.
Definition at line 317 of file source_exporter.py.
| None source_exporter.clean_source_dirs | ( | Path | root, |
| bool | dry_run = False ) |
| List[Path] source_exporter.collect_recursive_files | ( | Path | folder, |
| dict | cfg ) |
Definition at line 258 of file source_exporter.py.
| Tuple[int, int, int] source_exporter.get_file_stats | ( | Path | path | ) |
| dict source_exporter.load_exporter_config | ( | Path | root | ) |
Load optional per-project config, merging with module-level defaults.
Definition at line 151 of file source_exporter.py.
| None source_exporter.run_exporter | ( | Path | root, |
| list[str] | args ) |
Execute the source exporter with the given root directory and arguments.
Definition at line 431 of file source_exporter.py.
| bool source_exporter.should_skip_dirname | ( | str | dirname, |
| dict | cfg ) |
| source_exporter.walk_included_dirs | ( | Path | start, |
| dict | cfg ) |
Definition at line 289 of file source_exporter.py.
| source_exporter.write_source_file_for_dir | ( | Path | folder, |
| Path | output_path, | ||
| Path | root, | ||
| dict | cfg, | ||
| bool | warn_secrets = False, | ||
| bool | block_secrets = False, | ||
| set[Path] | None | diff_filter = None ) |
Definition at line 359 of file source_exporter.py.
|
protected |
Definition at line 144 of file source_exporter.py.
|
protected |
Definition at line 111 of file source_exporter.py.
|
protected |
Definition at line 142 of file source_exporter.py.
|
protected |
Definition at line 97 of file source_exporter.py.
|
protected |
Definition at line 60 of file source_exporter.py.
|
protected |
Definition at line 95 of file source_exporter.py.
| tuple source_exporter.HEADER_TEXT |
Definition at line 128 of file source_exporter.py.
| list source_exporter.INCLUDE_EXTENSIONS = [ext for exts in _EXTENSION_PROFILES.values() for ext in exts] |
Definition at line 122 of file source_exporter.py.
| str source_exporter.ROOT_HEADER = "####### Root directory: .\n\n" |
Definition at line 139 of file source_exporter.py.
| str source_exporter.SEPARATOR_FILE = "##### File name {num:02d}: {path}\n" |
Definition at line 137 of file source_exporter.py.
| str source_exporter.SEPARATOR_SUBDIR = "####### Subdirectory name {num:02d}: {dirname}\n" |
Definition at line 138 of file source_exporter.py.