Page MenuHomeSoftware Heritage

D5466.id19602.diff
No OneTemporary

D5466.id19602.diff

diff --git a/swh/model/cli.py b/swh/model/cli.py
--- a/swh/model/cli.py
+++ b/swh/model/cli.py
@@ -9,7 +9,15 @@
# WARNING: do not import unnecessary things here to keep cli startup time under
# control
-import click
+try:
+ import click
+except ImportError:
+ print(
+ "Cannot run swh-identify; the Click package is not installed."
+ "Please install 'swh.model[cli]' for full functionality.",
+ file=sys.stderr,
+ )
+ exit(1)
try:
from swh.core.cli import swh as swh_cli_group
@@ -101,7 +109,13 @@
def swhid_of_git_repo(path) -> CoreSWHID:
- import dulwich.repo
+ try:
+ import dulwich.repo
+ except ImportError:
+ raise click.ClickException(
+ "Cannot compute snapshot identifier; the Dulwich package is not installed. "
+ "Please install 'swh.model[cli]' for full functionality.",
+ )
from swh.model import hashutil
from swh.model.identifiers import snapshot_identifier

File Metadata

Mime Type
text/plain
Expires
Nov 5 2024, 6:42 AM (8 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220205

Event Timeline