Skip to content

Commit 0b90f3e

Browse files
authored
Merge pull request #149 from alisnwu/capture-user-fix
Added extra information in warning for better capturing of user info
2 parents 3aeeab8 + 5bfc9dd commit 0b90f3e

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

news/capture-user.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Better wording on the capture user info functionality
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/utils/tools.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ def _sorted_merge(*dicts):
7777

7878
def _create_global_config(args):
7979
username = input(
80-
f"Please enter the name of the user to put in the diffpy global config file "
81-
f"[{args.get('username', '')}]: "
80+
f"Please enter the name you would want future work to be credited to " f"[{args.get('username', '')}]: "
8281
).strip() or args.get("username", "")
83-
email = input(
84-
f"Please enter the email of the user to put in the diffpy global config file "
85-
f"[{args.get('email', '')}]: "
86-
).strip() or args.get("email", "")
82+
email = input(f"Please enter the your email " f"[{args.get('email', '')}]: ").strip() or args.get("email", "")
8783
return_bool = False if username is None or email is None else True
8884
with open(Path().home() / "diffpyconfig.json", "w") as f:
8985
f.write(json.dumps({"username": stringify(username), "email": stringify(email)}))
@@ -114,6 +110,15 @@ def get_user_info(args=None):
114110
global_config = load_config(Path().home() / "diffpyconfig.json")
115111
local_config = load_config(Path().cwd() / "diffpyconfig.json")
116112
if global_config is None and local_config is None:
113+
print(
114+
"No global configuration file was found containing "
115+
"information about the user to associate with the data.\n"
116+
"By following the prompts below you can add your name and email to this file on the current"
117+
" computer and your name will be automatically associated with subsequent diffpy data by default.\n"
118+
"This is not recommended on a shared or public computer. "
119+
"You will only have to do that once.\n"
120+
"For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html"
121+
)
117122
config_bool = _create_global_config(args)
118123
global_config = load_config(Path().home() / "diffpyconfig.json")
119124
config = _sorted_merge(clean_dict(global_config), clean_dict(local_config), clean_dict(args))

0 commit comments

Comments
 (0)