Skip to content

Added extra information in warning for better capturing of user info #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/capture-user.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Better wording on the capture user info functionality

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
17 changes: 11 additions & 6 deletions src/diffpy/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ def _sorted_merge(*dicts):

def _create_global_config(args):
username = input(
f"Please enter the name of the user to put in the diffpy global config file "
f"[{args.get('username', '')}]: "
f"Please enter the name you would want future work to be credited to " f"[{args.get('username', '')}]: "
).strip() or args.get("username", "")
email = input(
f"Please enter the email of the user to put in the diffpy global config file "
f"[{args.get('email', '')}]: "
).strip() or args.get("email", "")
email = input(f"Please enter the your email " f"[{args.get('email', '')}]: ").strip() or args.get("email", "")
return_bool = False if username is None or email is None else True
with open(Path().home() / "diffpyconfig.json", "w") as f:
f.write(json.dumps({"username": stringify(username), "email": stringify(email)}))
Expand Down Expand Up @@ -114,6 +110,15 @@ 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:
print(
"No global configuration file was found containing "
"information about the user to associate with the data.\n"
"By following the prompts below you can add your name and email to this file on the current"
" computer and your name will be automatically associated with subsequent diffpy data by default.\n"
"This is not recommended on a shared or public computer. "
"You will only have to do that once.\n"
"For more information, please refer to www.diffpy.org/diffpy.utils/examples/toolsexample.html"
)
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))
Expand Down