Skip to content

Commit 4ee36af

Browse files
committed
Add Error if pack or example doesnt exist
1 parent 10771b1 commit 4ee36af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/diffpy/cmi/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def copy_example(pack_example: str) -> Path:
7777
7878
Parameters
7979
----------
80-
example : str
80+
pack_example : str
8181
Pack and example name in the form ``<pack>/<exdir>``.
8282
8383
Returns
@@ -88,7 +88,7 @@ def copy_example(pack_example: str) -> Path:
8888
Raises
8989
------
9090
ValueError
91-
If the format is invalid.
91+
If the format is invalid (missing pack or example).
9292
FileNotFoundError
9393
If the example directory does not exist.
9494
FileExistsError
@@ -97,6 +97,11 @@ def copy_example(pack_example: str) -> Path:
9797
if "/" not in pack_example:
9898
raise ValueError("Example must be specified as <pack>/<exdir>")
9999
pack, exdir = pack_example.split("/", 1)
100+
if not pack or not exdir:
101+
raise ValueError(
102+
f"Invalid format for example '{pack_example}'. "
103+
"Must be '<pack>/<exdir>'"
104+
)
100105
src = _get_examples_dir() / pack / exdir
101106
if not src.exists() or not src.is_dir():
102107
raise FileNotFoundError(f"Example not found: {pack_example}")

0 commit comments

Comments
 (0)