scaffold_kit.checklist
Generates a checklist of files in a directory.
This module scans the current directory and creates a text-based checklist of
all files, excluding those specified in an ignore file (e.g., .gitignore).
Each file in the checklist is marked with an ‘[x]’ if it contains content or
‘[ ]’ if it is empty. The final checklist is saved to a file and printed to
the console.
Usage
To run this script, navigate to your project’s root directory and execute it as a module:
$ uv run python -m scaffold_kit.checklist
file_is_empty(file_path)
#
Checks if a file is empty by checking its size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The path to the file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the file’s size is 0 bytes, False otherwise. |
Source code in src/scaffold_kit/checklist.py
generate_checklist(ignore_file='.gitignore', output_file='checklist.txt', output_dir=None)
#
Generates a checklist of files and directories in the current directory.
The traversal is hierarchical. Within each directory, entries are sorted case-insensitively with directories first and then files. Directories are always marked “[x]”. Files are marked “[ ]” if empty and “[x]” otherwise. Paths matching patterns from the ignore file are skipped. The checklist is written to the output location and printed to stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ignore_file
|
str
|
Name of the ignore file with patterns (e.g., “.gitignore”). |
'.gitignore'
|
output_file
|
str
|
Name of the output checklist file. |
'checklist.txt'
|
output_dir
|
Optional[str]
|
Directory for the output file. Created if it does not exist. |
None
|
Raises:
| Type | Description |
|---|---|
OSError
|
If writing the checklist file fails due to I/O errors. |
Source code in src/scaffold_kit/checklist.py
main()
#
Main entry point to run the checklist generation process.
walk_sorted(base, root=None)
#
Walks a directory tree and returns relative paths in hierarchical order.
Directories appear before files within each directory, both sorted case-insensitively. Parent directories are listed before their children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
Path
|
The base path to walk. |
required |
root
|
Path | None
|
The root used to compute relative paths. Defaults to the base. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of relative paths as strings in stable, hierarchical order. |