From 7112fac0c7804badf4ad41733cabec0960f063ff Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 16:31:25 -0500 Subject: [PATCH 1/3] Add warning to missing global config file --- news/get-user-fix.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/tools.py | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 news/get-user-fix.rst diff --git a/news/get-user-fix.rst b/news/get-user-fix.rst new file mode 100644 index 00000000..5b2fd3df --- /dev/null +++ b/news/get-user-fix.rst @@ -0,0 +1,23 @@ +**Added:** + +* Warning message for missing global config file + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 1dfb8284..dc908a27 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -3,6 +3,7 @@ import os from copy import copy from pathlib import Path +import warnings def clean_dict(obj): @@ -114,6 +115,7 @@ def get_user_info(args=None): global_config = load_config(Path().home() / "diffpyconfig.json") local_config = load_config(Path().cwd() / "diffpyconfig.json") if global_config is None and local_config is None: + warnings.warn("No global config file, please follow prompts below. For more information, refer to www.diffpy.org/diffpy.utils/") config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From d24acb6305e6c9247618fc20b9633162b1096e79 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Tue, 5 Nov 2024 16:39:23 -0500 Subject: [PATCH 2/3] fix line too long --- src/diffpy/utils/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index dc908a27..7574d093 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -115,7 +115,7 @@ def get_user_info(args=None): global_config = load_config(Path().home() / "diffpyconfig.json") local_config = load_config(Path().cwd() / "diffpyconfig.json") if global_config is None and local_config is None: - warnings.warn("No global config file, please follow prompts below. For more information, refer to www.diffpy.org/diffpy.utils/") + warnings.warn("No global config file, please follow prompts below.") config_bool = _create_global_config(args) global_config = load_config(Path().home() / "diffpyconfig.json") config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args)) From 97d37f224f9c412aea6a4b8014c7ca7f69cce837 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:42:37 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit hooks --- src/diffpy/utils/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/utils/tools.py b/src/diffpy/utils/tools.py index 7574d093..cf8b6707 100644 --- a/src/diffpy/utils/tools.py +++ b/src/diffpy/utils/tools.py @@ -1,9 +1,9 @@ import importlib.metadata import json import os +import warnings from copy import copy from pathlib import Path -import warnings def clean_dict(obj):