|
Option C Tools
|
Functions | |
| str | _make_header (str rel_posix) |
| str | _derive_import_path (str rel_posix) |
| None | _print_content (str label, str content) |
| create_new_file (Path project_root, str path, bool force, bool dry_run=False, bool test=False, bool verbose=False) | |
Variables | |
| str | SHEBANG = "#!/usr/bin/env python3" |
| str | ENCODING = "# -*- coding: utf-8 -*-" |
| str | IMPORT_BLOCK = "from oc_diagnostics import _dbg\n\n" |
| str | DOCSTRING_TEMPLATE |
| str | TEST_DOCSTRING_TEMPLATE |
| str | TEST_BODY_TEMPLATE |
File Generator
==============
Purpose
-------
Create new Option C-compliant Python files with the mandatory 3-line header
block and a complete module docstring skeleton, ready for immediate development.
Responsibilities
----------------
- Accept a target path relative to or absolute from the project root.
- Write the mandatory 3-line header block (shebang, encoding, file identity).
- Append the ``from oc_diagnostics import _dbg`` import so the generated file
is immediately linter-compliant for ``_dbg`` usage checks.
- Append the Option C docstring template including the Diagnostics section.
- Refuse to overwrite existing files unless ``--force`` is explicitly requested.
Diagnostics
-----------
Domain: OCT-GENERATOR
Levels:
L2 — lifecycle
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Must not overwrite existing files unless ``force=True``.
- Generated file must pass the OCT linter header and docstring checks immediately.
- Target path may be absolute or relative to the project root.
|
protected |
Convert a relative posix path to a dotted Python import path (without .py).
Definition at line 111 of file new_python_file.py.
|
protected |
Build the 4-line Option C header block (shebang, encoding, identity, blank).
Definition at line 106 of file new_python_file.py.
|
protected |
Print generated file content with a visual frame.
Definition at line 117 of file new_python_file.py.
| new_python_file.create_new_file | ( | Path | project_root, |
| str | path, | ||
| bool | force, | ||
| bool | dry_run = False, | ||
| bool | test = False, | ||
| bool | verbose = False ) |
| str new_python_file.DOCSTRING_TEMPLATE |
Definition at line 49 of file new_python_file.py.
| str new_python_file.ENCODING = "# -*- coding: utf-8 -*-" |
Definition at line 43 of file new_python_file.py.
| str new_python_file.IMPORT_BLOCK = "from oc_diagnostics import _dbg\n\n" |
Definition at line 47 of file new_python_file.py.
| str new_python_file.SHEBANG = "#!/usr/bin/env python3" |
Definition at line 42 of file new_python_file.py.
| str new_python_file.TEST_BODY_TEMPLATE |
Definition at line 96 of file new_python_file.py.
| str new_python_file.TEST_DOCSTRING_TEMPLATE |
Definition at line 72 of file new_python_file.py.