Igor Utils¶
igor.py
utils
- drain_swamp.igor_utils._logger: logging.Logger¶
Module level logger
- drain_swamp.igor_utils.__all__: tuple[str, str, str, str, str, str, str] = ("seed_changelog", "edit_for_release", "build_package", "pretag", "print_cheats", "get_tag_version", "write_version_file")¶
Module level exports
- drain_swamp.igor_utils.SCRIV_START: str = ".. scriv-start-here\n\n"¶
In
CHANGES.rst
, token beneath which a changelog entry is written
- drain_swamp.igor_utils.UNRELEASED: str = "Unreleased\n----------"¶
Written into
CHANGES.rst
, the start of what is being called, the seed
- drain_swamp.igor_utils.REGEX_COPYRIGHT_LINE: str¶
NOTICE.txt
has a start and end year. Regex for grabbing both.
- drain_swamp.igor_utils.COPYRIGHT_START_YEAR_FALLBACK: int = 1970¶
Fallback start year.
NOTICE.txt
start year gets updated. Since the start year is static expected to be provided inpyproject.toml
- drain_swamp.igor_utils.build_package(path, kind)¶
Build package.
Replaces / obsoletes
python igor.py build_next "0.0.1" python igor.py build_next "tag" python igor.py build_next "current" python igor.py build_next "now"
- Parameters:
path¶ (pathlib.Path) – Current working directory path
kind¶ (str) – version str, “tag”, or “current” or “now”. For tagged versions, a version str
- Returns:
True if build succeeded otherwise False
- Return type:
- Raises:
NotADirectoryError
– cwd is not a folderAssertionError
– Could not get package name from gitValueError
– Explicit version str invalid
Caution
side effect
kind will update [app name]/src/_version.py (done by setupttools-scm)
- drain_swamp.igor_utils.edit_for_release(path_cwd, kind, snippet_co=None)¶
Edit a few files in preparation for a release.
[tool.drain-swamp] copyright_start_year = [an int]
app name also taken from pyproject.toml
- Parameters:
- Returns:
None if no error occurred. 3 if no folder, 4 if no doc?/conf.py file. 2 version str was dodgy
- Return type:
int | None
- drain_swamp.igor_utils.get_tag_version(path)¶
Specifically want version from version file, not current version from setuptools-scm and git.
If
pyproject.toml
is missing or malformed raiseAssertionError
.For all other issues, issue a warning and fallback to current version. Always want a semantic version str, even if it’s wrong. The warning will indicate what needs to be fixed
- Parameters:
path¶ (pathlib.Path) – current working directory path
is_test¶ (bool | None) – Default False. During testing set to True
- Returns:
tag version fall back to current version
- Return type:
- Raises:
NotADirectoryError
– cwd is not a folderAssertionError
– pyproject.toml is missing or malformedValueError
– Explicit version str invalid
- drain_swamp.igor_utils.pretag(tag)¶
Idiot check / sanitize proposed tag.
Validates semantic version str. Printing the fix semantic tag.
- drain_swamp.igor_utils.print_cheats(path, kind)¶
Print cheats.
- Parameters:
path¶ (pathlib.Path) – current working directory path
kind¶ (str) – version str, “tag”, or “current” or “now”. For tagged versions, a version str
- Raises:
NotADirectoryError
– cwd is not a folderAssertionError
– Could not get package name from gitValueError
– Explicit version str invalid
- drain_swamp.igor_utils.seed_changelog(path_cwd)¶
Add a new empty changelog entry
- Parameters:
path_cwd¶ (pathlib.Path) – Current working directory path
- Returns:
0 success 1 missing start token 2 file not found or permissions issue
- Return type:
- drain_swamp.igor_utils.write_version_file(path, kind, is_test=False)¶
Writes version file. Uses vendored setuptools-scm code.
From pyproject.toml requires:
project.name
tool.pipenv-unlock.version_file
- Parameters:
- Raises:
NotADirectoryError
– cwd is not a folderAssertionError
– Could not get package name from pyproject.tomlValueError
– Explicit version str invalidValueError
– Only support write to .py or .txt file