Cleaning projects#
Projects usually become cluttered with obsolete files after some time.
To clean the project, type pytask clean
$ pytask clean
──────────────────────────── Start pytask session ────────────────────────────
Platform: win32 -- Python <span style="color: var(--termynal-blue)">3.10.0</span>, pytask <span style="color: var(--termynal-blue)">0.4.0</span>, pluggy <span style="color: var(--termynal-blue)">1.0.0</span>
Root: C:\Users\pytask-dev\git\my_project
Collected <span style="color: var(--termynal-blue)">1</span> task.
Files which can be removed:
Would remove svgs/obsolete_file_1.md
Would remove svgs/obsolete_folder/obsolete_file_2.md
Would remove svgs/obsolete_folder/obsolete_file_3.md
──────────────────────────────────────────────────────────────────────────────
pytask performs a dry-run by default and lists all removable files.
If you want to remove the files, use pytask clean --mode
with one of the
following modes.
force
removes all files suggested in thedry-run
without any confirmation.interactive
allows you to decide for every file whether to keep it or not.
If you want to delete complete folders instead of single files, use
pytask clean --directories
.
$ pytask clean --directories
──────────────────────────── Start pytask session ────────────────────────────
Platform: win32 -- Python <span style="color: var(--termynal-blue)">3.10.0</span>, pytask <span style="color: var(--termynal-blue)">0.4.0</span>, pluggy <span style="color: var(--termynal-blue)">1.0.0</span>
Root: C:\Users\pytask-dev\git\my_project
Collected <span style="color: var(--termynal-blue)">1</span> task.
Files which can be removed:
Would remove svgs/obsolete_file_1.md
Would remove svgs/obsolete_folder
──────────────────────────────────────────────────────────────────────────────
Excluding files#
pytask excludes files that are under version control with git.
Use the pytask clean --exclude
option or the exclude
key in the
configuration file to exclude files and directories.
Values can be Unix filename patterns that, for example, support the wildcard character
*
for any characters. You find the documentation in fnmatch
.
Here is an example for excluding a folder.
$ pytask clean --exclude obsolete_folder
or
[tool.pytask.ini_options]
exclude = ["obsolete_folder"]