Skip to content

Commit

Permalink
Deprecate print_version() (moved to cli_base)
Browse files Browse the repository at this point in the history
e.g.:
```
-from manageprojects.utilities.version_info import print_version
+from cli_base.cli_tools.version_info import print_version
```

Code moved, see: jedie/cli-base-utilities#6
  • Loading branch information
jedie committed Aug 17, 2023
1 parent a3ccc02 commit ef0420e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 85 deletions.
2 changes: 1 addition & 1 deletion manageprojects/cli/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import rich_click as click
from bx_py_utils.path import assert_is_dir, assert_is_file
from cli_base.cli_tools.subprocess_utils import verbose_check_call
from cli_base.cli_tools.version_info import print_version
from rich import print # noqa
from rich_click import RichGroup

Expand All @@ -30,7 +31,6 @@
from manageprojects.data_classes import CookiecutterResult
from manageprojects.format_file import format_one_file
from manageprojects.utilities.log_utils import log_config
from manageprojects.utilities.version_info import print_version


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion manageprojects/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import rich_click as click
from bx_py_utils.path import assert_is_file
from cli_base.cli_tools.subprocess_utils import verbose_check_call
from cli_base.cli_tools.version_info import print_version
from rich import print # noqa; noqa
from rich_click import RichGroup

import manageprojects
from manageprojects import constants
from manageprojects.utilities import code_style
from manageprojects.utilities.publish import publish_package
from manageprojects.utilities.version_info import print_version


logger = logging.getLogger(__name__)
Expand Down
44 changes: 0 additions & 44 deletions manageprojects/tests/test_version_info.py

This file was deleted.

44 changes: 12 additions & 32 deletions manageprojects/utilities/version_info.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
import logging
from pathlib import Path
import warnings

from rich import print # noqa
from cli_base.cli_tools.version_info import print_version as new_print_version

from manageprojects.git import Git


logger = logging.getLogger(__name__)


def _print_version(module, project_root: Path = None):
print(f'[bold][green]{module.__name__}[/green] v', end='')
print(module.__version__, end=' ')

if not project_root:
project_root = Path(module.__file__).parent.parent
git_path = project_root / '.git'
if git_path.is_dir():
git = Git(cwd=git_path)
current_hash = git.get_current_hash(verbose=False)
print(f'[blue]{current_hash}[/blue]', end=' ')
print(f'([white]{git.cwd}[/white])')
else:
print(f'(No git found for: {project_root})')


def print_version(module, project_root: Path = None) -> None:
try:
_print_version(module=module, project_root=project_root)
except Exception as err:
logger.exception('Error print version: %s', err)

# Catch all errors, otherwise the CLI is not usable ;)
print(f'{module} (print version error: {err})')
def print_version(*args, **kwargs) -> None:
"""
DEPRECATED: Migrate to: cli_base.cli_tools.version_info.print_version !
"""
warnings.warn(
'Migrate to: cli_base.cli_tools.version_info.print_version !',
DeprecationWarning,
stacklevel=2,
)
new_print_version(*args, **kwargs)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"codespell", # https://github.com/codespell-project/codespell
"mypy", # https://github.com/python/mypy

"cli-base-utilities", # https://github.com/jedie/cli-base-utilities
"cli-base-utilities>=0.3.0", # https://github.com/jedie/cli-base-utilities
"click", # https://github.com/pallets/click/
"rich-click", # https://github.com/ewels/rich-click
"rich", # https://github.com/Textualize/rich
Expand Down
6 changes: 3 additions & 3 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ charset-normalizer==3.2.0 \
--hash=sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac \
--hash=sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa
# via requests
cli-base-utilities==0.2.0 \
--hash=sha256:4fb89f4980c45eeeae69c7d745ddf7449740d42a072a42dd2c46ae1519ad7128 \
--hash=sha256:5edd26c07063ab031e30712c80fd3b8a2b9dffe33143ebd25cb1bc932a55488e
cli-base-utilities==0.3.0 \
--hash=sha256:1a59a0a61d853b4d3f4944e7494af139bccb3cca4e7766e94f452c2f131a1d59 \
--hash=sha256:ca73cf149e5fd10312d450d9919a1ed87222c7bdd6479e94ab670ece4d91e8ba
# via manageprojects (pyproject.toml)
click==8.1.6 \
--hash=sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd \
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ charset-normalizer==3.2.0 \
--hash=sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac \
--hash=sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa
# via requests
cli-base-utilities==0.2.0 \
--hash=sha256:4fb89f4980c45eeeae69c7d745ddf7449740d42a072a42dd2c46ae1519ad7128 \
--hash=sha256:5edd26c07063ab031e30712c80fd3b8a2b9dffe33143ebd25cb1bc932a55488e
cli-base-utilities==0.3.0 \
--hash=sha256:1a59a0a61d853b4d3f4944e7494af139bccb3cca4e7766e94f452c2f131a1d59 \
--hash=sha256:ca73cf149e5fd10312d450d9919a1ed87222c7bdd6479e94ab670ece4d91e8ba
# via manageprojects (pyproject.toml)
click==8.1.6 \
--hash=sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd \
Expand Down

0 comments on commit ef0420e

Please sign in to comment.