You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/toolsexample.html
+31-13Lines changed: 31 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@
78
78
79
79
<sectionid="id1">
80
80
<h1>Tools Example<aclass="headerlink" href="#id1" title="Link to this heading"></a></h1>
81
-
<p>This example will demonstrate how diffpy.utils allows us to load and manage username and email information.
81
+
<p>This example will demonstrate how diffpy.utils allows us to conveniently load and manage user and package information.
82
82
Using the tools module, we can efficiently get them in terms of a dictionary.</p>
83
83
<olclass="arabic">
84
84
<li><p>We have the function <codeclass="docutils literal notranslate"><spanclass="pre">get_user_info</span></code> that neatly returns a dictionary containing the username and email.
@@ -87,22 +87,22 @@ <h1>Tools Example<a class="headerlink" href="#id1" title="Link to this heading">
<p>This function will first attempt to load configuration files
91
-
from both the current working directory and the home directory.
92
-
If no configuration files exist, it prompts for user input and creates a configuration file in the home directory.
93
-
It prioritizes prompted user inputs, then current working directory, and finally home directory.
94
-
If no configuration files or inputs are found, this function creates a configuration in the home directory
95
-
with empty values for username and email stored as a dictionary.</p>
90
+
<p>This function will first attempt to load the information from configuration files looking first in
91
+
the current working directory and then in the user’s home directory.
92
+
If no configuration files exist, it prompts for user input and creates a configuration file in the home directory
93
+
so that the next time the program is run it will no longer have to prompt the user.
94
+
It can be passed user information which overrides looking in config files, and so could be passed
95
+
information that is entered through a gui or command line interface to override default information at runtime.
96
+
It prioritizes prompted user inputs, then current working directory config file, and finally home directory config file.</p>
97
+
<p>The function returns a dictionary containing the username and email information.</p>
96
98
</li>
97
-
<li><p>You can also override existing values by passing a dictionary to the function.</p>
99
+
<li><p>You can also override existing values by passing a dictionary to the function with the keys <cite>“username”</cite> and <cite>“email”</cite></p>
@@ -116,7 +116,25 @@ <h1>Tools Example<a class="headerlink" href="#id1" title="Link to this heading">
116
116
<p>This updates the email to “<aclass="reference external" href="mailto:new%40email.com">new<span>@</span>email<span>.</span>com</a>” while fetching the username from inputs or the configuration files.</p>
117
117
</li>
118
118
</ol>
119
-
<p>By using this function, we ensure that user information is correctly loaded, merged, and saved.</p>
119
+
<olclass="arabic" start="3">
120
+
<li><p>We also have the function <codeclass="docutils literal notranslate"><spanclass="pre">get_package_info</span></code>, which inserts or updates package names and versions
121
+
in the given metadata dictionary under the key “package_info”.
122
+
It stores the package information as {“package_info”: {“package_name”: “version_number”}}.
0 commit comments