Skip to content

Commit 0186c51

Browse files
committed
skpkg: add conftest.py, add cli utility from skpkg
1 parent 04b8365 commit 0186c51

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
4949
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5050

5151
[project.scripts]
52-
diffpy-distanceprinter = "diffpy.distanceprinter:main"
52+
diffpy-distanceprinter = "diffpy.distanceprinter.distanceprinter_app:main"
5353

5454
[tool.setuptools.dynamic]
5555
dependencies = {file = ["requirements/pip.txt"]}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import argparse
2+
3+
from diffpy.distanceprinter.version import __version__ # noqa
4+
5+
6+
def main():
7+
parser = argparse.ArgumentParser(
8+
prog="diffpy.distanceprinter",
9+
description=(
10+
"Distance Printer, calculate the inter atomic distances. Part of xPDFsuite.\n\n"
11+
"For more information, visit: "
12+
"https://github.com/diffpy/diffpy.distanceprinter/"
13+
),
14+
formatter_class=argparse.RawDescriptionHelpFormatter,
15+
)
16+
17+
parser.add_argument(
18+
"--version",
19+
action="store_true",
20+
help="Show the program's version number and exit",
21+
)
22+
23+
args = parser.parse_args()
24+
25+
if args.version:
26+
print(f"diffpy.distanceprinter {__version__}")
27+
else:
28+
# Default behavior when no arguments are given
29+
parser.print_help()
30+
31+
32+
if __name__ == "__main__":
33+
main()

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
7+
@pytest.fixture
8+
def user_filesystem(tmp_path):
9+
base_dir = Path(tmp_path)
10+
home_dir = base_dir / "home_dir"
11+
home_dir.mkdir(parents=True, exist_ok=True)
12+
cwd_dir = base_dir / "cwd_dir"
13+
cwd_dir.mkdir(parents=True, exist_ok=True)
14+
15+
home_config_data = {"username": "home_username", "email": "home@email.com"}
16+
with open(home_dir / "diffpyconfig.json", "w") as f:
17+
json.dump(home_config_data, f)
18+
19+
yield tmp_path

0 commit comments

Comments
 (0)