Skip to content

Commit f3be5a6

Browse files
authored
Merge pull request #242 from alisnwu/tools-doc-update
updated tools example doc with better get_user_info example
2 parents e6a006d + 9f48f34 commit f3be5a6

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

Diff for: doc/source/examples/toolsexample.rst

+26-12
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,44 @@ Using the tools module, we can efficiently get them in terms of a dictionary.
2424

2525
The function returns a dictionary containing the username and email information.
2626

27-
2) You can also override existing values by passing a dictionary to the function with the keys ``"username"`` and ``"email"`` ::
27+
2) There are a few ways you could use to override the user information in the configuration files
28+
* You can override existing values by passing a dictionary to the function with the keys ``"username"`` and ``"email"`` ::
2829

29-
new_args = {"username": "new_username", "email": "[email protected]"}
30-
new_user_info = get_user_info(new_args)
30+
new_args = {"username": "new_username", "email": "[email protected]"}
31+
new_user_info = get_user_info(new_args)
3132

32-
3) You can update only the username or email individually, for example ::
33+
This returns "new_username" and "[email protected]" instead of the
34+
* You can update only the username or email individually, for example ::
3335

34-
new_username = {"username": new_username}
35-
new_user_info = get_user_info(new_username)
36+
new_username = {"username": new_username}
37+
new_user_info = get_user_info(new_username)
3638

37-
This updates username to "new_username" while fetching the email from inputs or the configuration files.
38-
Similarly, you can update only the email. ::
39+
This updates username to "new_username" while fetching the email from inputs or the configuration files.
40+
Similarly, you can update only the email. ::
3941

40-
new_email = {"email": [email protected]}
41-
new_user_info = get_user_info(new_email)
42+
new_email = {"email": [email protected]}
43+
new_user_info = get_user_info(new_email)
4244

43-
This updates the email to "[email protected]" while fetching the username from inputs or the configuration files.
45+
This updates the email to "[email protected]" while fetching the username from inputs or the configuration files.
46+
47+
3) You can also permanently update your default configuration file manually.
48+
Locate the file ``diffpyconfig.json``, which is usually in the user's home directory (``~/.diffpy/``) or ``~/.config/diffpy/``.
49+
Open the file using a text editor such as nano, vim, or a graphical editor like VS Code.
50+
Look for entries like these ::
51+
52+
{
53+
"username": "John Doe",
54+
"email": "[email protected]"
55+
}
56+
57+
Then you can update the username and email as needed, make sure to save your edits.
4458

4559
4) We also have the function ``get_package_info``, which inserts or updates package names and versions
4660
in the given metadata dictionary under the key "package_info".
4761
It stores the package information as {"package_info": {"package_name": "version_number"}}.
4862
This function can be used as follows. ::
4963

50-
from diffpy.utils.tools import get_user_info
64+
from diffpy.utils.tools import get_package_info
5165
package_metadata = get_package_info("my_package")
5266

5367
You can also specify an existing dictionary to be updated with the information. ::

Diff for: news/tools-doc-update.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Information on how to update the default user information
4+
5+
**Changed:**
6+
7+
* Enumerated list for the different ways to set user information
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Typo for get_package_info example
20+
21+
**Security:**
22+
23+
* <news item>

0 commit comments

Comments
 (0)