-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from jedie/dev
Deprecate print_version()
- Loading branch information
Showing
7 changed files
with
21 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters