Skip to content

Commit d3b531c

Browse files
committed
change variable name to reflect action properly
1 parent 3a1ee8b commit d3b531c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/diffpy/cmi/cli.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def map_packs_to_examples() -> dict[str, List[str]]:
7272
return examples_by_pack
7373

7474

75-
def copy_example(example: str) -> Path:
75+
def copy_example(pack_example: str) -> Path:
7676
"""Copy an example into the current working directory.
7777
7878
Parameters
@@ -94,12 +94,12 @@ def copy_example(example: str) -> Path:
9494
FileExistsError
9595
If the destination directory already exists.
9696
"""
97-
if "/" not in example:
97+
if "/" not in pack_example:
9898
raise ValueError("Example must be specified as <pack>/<exdir>")
99-
pack, exdir = example.split("/", 1)
99+
pack, exdir = pack_example.split("/", 1)
100100
src = _installed_examples_dir() / pack / exdir
101101
if not src.exists() or not src.is_dir():
102-
raise FileNotFoundError(f"Example not found: {example}")
102+
raise FileNotFoundError(f"Example not found: {pack_example}")
103103
dest = Path.cwd() / exdir
104104
if dest.exists():
105105
raise FileExistsError(f"Destination {dest} already exists")
@@ -348,13 +348,9 @@ def _cmd_example(ns: argparse.Namespace) -> int:
348348
)
349349
ns._parser.print_help()
350350
return 1
351-
try:
352-
out = copy_example(name)
353-
print(f"Example copied to: {out}")
354-
return 0
355-
except (ValueError, FileNotFoundError, FileExistsError) as e:
356-
plog.error("%s", e)
357-
return 1
351+
out = copy_example(name)
352+
print(f"Example copied to: {out}")
353+
return 0
358354
if ns.example_cmd == "list":
359355
for pack, examples in map_packs_to_examples().items():
360356
print(f"{pack}:")

0 commit comments

Comments
 (0)