worm-library 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ from .downloader import get_worm_tour, get_introduction_demo
2
+ from .downloader import get_reaction_properties_demo, get_univariant_curve_demo
3
+ from .downloader import get_intro_aqueous_speciation_demo, get_multi_aqueous_speciation_demo, get_charge_balance_demo, get_heterogeneous_equilibrium_demo, get_heterogeneous_equilibrium_gas_demo, get_alter_suppress_demo, get_custom_data0_demo, get_EQ3_demo, get_EQ6_demo, get_intro_mass_transfer_demo, get_mass_transfer_feature_demo, get_mixing_demo, get_speciation_datasets_demo, get_energy_supply_demo
4
+ from .downloader import get_intro_aqorg_demo, get_aqorg_feature_demo, get_complicator_demo, get_estimate_HKF_demo
5
+ from .downloader import get_workshop_demo, delete_all_demos
6
+ from .downloader import get_Weeks_2025_demo, get_Trinh_2026_demo, get_whats_in_water_demo
@@ -0,0 +1,209 @@
1
+ from urllib.request import urlopen, urlretrieve
2
+ from pathlib import Path
3
+ import shutil
4
+ from bs4 import BeautifulSoup as bs
5
+ import requests
6
+ import os
7
+ from glob import glob
8
+ from shutil import rmtree
9
+ import json
10
+ import re
11
+
12
+ def get_WORM_demo(demo_name, URL):
13
+
14
+ # check to see if this notebook is being run inside of the read-only WORM Library folder
15
+ cwd = os.getcwd()
16
+
17
+ # main and raw URL prefixes for the WORM library
18
+ URL_main_prefix = 'https://github.com/worm-portal/WORM-Library/tree/master/'
19
+ URL_raw_prefix = 'https://raw.githubusercontent.com/worm-portal/WORM-Library/master/'
20
+
21
+ # delete demo folder if it exists
22
+ dirpath = Path(demo_name)
23
+ if dirpath.exists() and dirpath.is_dir():
24
+ shutil.rmtree(dirpath)
25
+
26
+ # create a fresh demo folder
27
+ dirpath.mkdir()
28
+
29
+ res = requests.get(URL_main_prefix+URL)
30
+ soup = bs(res.text, 'lxml')
31
+ # repo_files = soup.find_all('a', class_="js-navigation-open")
32
+
33
+ #gitstr = str(soup.find_all('p')[0])
34
+
35
+ try:
36
+ try:
37
+ gitstr = str([s for s in soup.find_all('script') if "payload" in str(s)][0])
38
+ gitstr = gitstr.split(">")[1].split("<")[0]
39
+ repo_files = [d["path"].split(URL+"/")[1] for d in json.loads(gitstr)["payload"]["tree"]["items"]]
40
+ except:
41
+ gitstr = str([s for s in soup.find_all('script') if "payload" in str(s)][1])
42
+ gitstr = gitstr.split(">")[1].split("<")[0]
43
+ repo_files = [d["path"].split(URL+"/")[1] for d in json.loads(gitstr)["payload"]["tree"]["items"]]
44
+
45
+ # correct for ampersand in file names
46
+ # e.g., S&amp;C10vents.csv becomes S&C10vents.csv
47
+ repo_files = [re.sub("&amp;", "&", f) for f in repo_files]
48
+ except:
49
+ raise Exception("The WORM Library is currently experiencing difficulty connecting to GitHub where demos are "
50
+ "hosted. Please inform Grayson Boyer gmboyer@asu.edu")
51
+
52
+ files = []
53
+ for i in repo_files:
54
+ if ('.csv' in i or '.ipynb' in i or '.3i' in i or '.6i' in i or '.cmp' in i or '.speciation' in i) and '.ipynb_checkpoints' not in i:
55
+ files.append(i)
56
+
57
+ for file in files:
58
+ if '.speciation' not in file:
59
+ # Download from URL and decode as UTF-8 text.
60
+ with urlopen(URL_raw_prefix+URL+"/"+file) as webpage:
61
+ content = webpage.read().decode()
62
+
63
+ # Save to file.
64
+ with open(demo_name+"/"+file, 'w') as output:
65
+ output.write(content)
66
+ else:
67
+ urlretrieve(URL_raw_prefix+URL+"/"+file, demo_name+"/"+file)
68
+
69
+ print(demo_name+" is ready.")
70
+
71
+
72
+ def get_worm_tour():
73
+ demo_name = "Demo-0-WORM-Tour"
74
+ URL = "WORM-Tour"
75
+ get_WORM_demo(demo_name, URL)
76
+
77
+ def get_introduction_demo():
78
+ demo_name = "Demo-1-Introduction"
79
+ URL = "1-Introduction"
80
+ get_WORM_demo(demo_name, URL)
81
+
82
+ def get_reaction_properties_demo():
83
+ demo_name = "Demo-2-(1-2-3)-Reaction-Properties"
84
+ URL = "2-Reaction-Properties"
85
+ get_WORM_demo(demo_name, URL)
86
+
87
+ def get_univariant_curve_demo():
88
+ demo_name = "Demo-2-4-Geothermometry-Univariant"
89
+ URL = "2-Reaction-Properties/4-Univariant-Curves"
90
+ get_WORM_demo(demo_name, URL)
91
+
92
+ def get_intro_aqueous_speciation_demo():
93
+ demo_name = "Demo-3-1-Intro-Aqueous_Speciation"
94
+ URL = "3-Aqueous-Speciation/1-Introduction-to-Aq-Speciation"
95
+ get_WORM_demo(demo_name, URL)
96
+
97
+ def get_multi_aqueous_speciation_demo():
98
+ demo_name = "Demo-3-2-Multi-Aqueous_Speciation"
99
+ URL = "3-Aqueous-Speciation/2-Multi-Sample-Speciation"
100
+ get_WORM_demo(demo_name, URL)
101
+
102
+ def get_charge_balance_demo():
103
+ demo_name = "Demo-3-3-Charge-Balance"
104
+ URL = "3-Aqueous-Speciation/3-Charge-Balancing"
105
+ get_WORM_demo(demo_name, URL)
106
+
107
+ def get_heterogeneous_equilibrium_demo():
108
+ demo_name = "Demo-3-4-1-Heterogeneous-Equilibrium"
109
+ URL = "3-Aqueous-Speciation/4-Custom-Database/1-Introduction"
110
+ get_WORM_demo(demo_name, URL)
111
+
112
+ def get_heterogeneous_equilibrium_gas_demo():
113
+ demo_name = "Demo-3-4-2-Gas-Equilibrium"
114
+ URL = "3-Aqueous-Speciation/Heterogeneous-Equil-Dissolve-Gas"
115
+ get_WORM_demo(demo_name, URL)
116
+
117
+ def get_alter_suppress_demo():
118
+ demo_name = "Demo-3-5-Alter-Suppress"
119
+ URL = "3-Aqueous-Speciation/5-Alter-and-Suppress"
120
+ get_WORM_demo(demo_name, URL)
121
+
122
+ def get_EQ3_demo():
123
+ demo_name = "Demo-3-6-1-EQ3"
124
+ URL = "3-Aqueous-Speciation/6-Extras/speciate-3i-file"
125
+ get_WORM_demo(demo_name, URL)
126
+
127
+ def get_EQ6_demo():
128
+ demo_name = "Demo-3-6-2-EQ6"
129
+ URL = "3-Aqueous-Speciation/6-Extras/speciate-6i-file"
130
+ get_WORM_demo(demo_name, URL)
131
+
132
+ def get_custom_data0_demo():
133
+ demo_name = "Demo-3-6-3-Custom-data0"
134
+ URL = "3-Aqueous-Speciation/4-Custom-Database/2-Creating-data0-files"
135
+ get_WORM_demo(demo_name, URL)
136
+
137
+ def get_intro_mass_transfer_demo():
138
+ demo_name = "Demo-3-7-1-Intro-Mass-Transfer"
139
+ URL = "3-Aqueous-Speciation/7-Mass-Transfer/1-Introduction"
140
+ get_WORM_demo(demo_name, URL)
141
+
142
+ def get_mass_transfer_feature_demo():
143
+ demo_name = "Demo-3-7-2-Mass-Transfer-Features"
144
+ URL = "3-Aqueous-Speciation/7-Mass-Transfer/2-Feature-Demo"
145
+ get_WORM_demo(demo_name, URL)
146
+
147
+ def get_mixing_demo():
148
+ demo_name = "Demo-3-7-3-Mixing-Fluids"
149
+ URL = "3-Aqueous-Speciation/7-Mass-Transfer/3-Fluid-Mixing"
150
+ get_WORM_demo(demo_name, URL)
151
+
152
+ def get_speciation_datasets_demo():
153
+ demo_name = "Demo-3-8-Dataset-Exploration"
154
+ URL = "3-Aqueous-Speciation/6-Extras/speciation-datasets"
155
+ get_WORM_demo(demo_name, URL)
156
+
157
+ def get_energy_supply_demo():
158
+ demo_name = "Demo-3-9-Energy-Supplies"
159
+ URL = "3-Aqueous-Speciation/Intro-to-Energy-Supplies"
160
+ get_WORM_demo(demo_name, URL)
161
+
162
+ def get_intro_aqorg_demo():
163
+ demo_name = "Demo-4-1-1-Intro-AqOrg"
164
+ URL = "4-Thermodynamic-Property-Estimation"
165
+ get_WORM_demo(demo_name, URL)
166
+
167
+ def get_aqorg_feature_demo():
168
+ demo_name = "Demo-4-1-2-AqOrg-Features"
169
+ URL = "4-Thermodynamic-Property-Estimation/Aq-Organics-Feature-Demo"
170
+ get_WORM_demo(demo_name, URL)
171
+
172
+ def get_complicator_demo():
173
+ demo_name = "Demo-4-2-1-WORM-Complicator"
174
+ URL = "4-Thermodynamic-Property-Estimation/Complicator"
175
+ get_WORM_demo(demo_name, URL)
176
+
177
+ def get_estimate_HKF_demo():
178
+ demo_name = "Demo-4-3-Estimate-HKF-Parameters"
179
+ URL = "4-Thermodynamic-Property-Estimation/Estimate-HKF-Parameters"
180
+ get_WORM_demo(demo_name, URL)
181
+
182
+ def get_Weeks_2025_demo():
183
+ demo_name = "Demo-5-Ammonia-Speciation-Weeks-et-al-2025"
184
+ URL = "5-Community-WORM-Notebooks/Ammonia-Speciation-Weeks-et-al-2025"
185
+ get_WORM_demo(demo_name, URL)
186
+
187
+ def get_Trinh_2026_demo():
188
+ demo_name = "Demo-5-Europa-Methanogenesis-Trinh-et-al-2026"
189
+ URL = "5-Community-WORM-Notebooks/Europa-Methanogenesis-Trinh-et-al-2026"
190
+ get_WORM_demo(demo_name, URL)
191
+
192
+ def get_whats_in_water_demo():
193
+ demo_name = "Demo-5-Whats-In-Your-Water-Weeks-Debes-2025"
194
+ URL = "5-Community-WORM-Notebooks/Whats-In-Your-Water-Weeks-Debes-2025"
195
+ get_WORM_demo(demo_name, URL)
196
+
197
+ def get_workshop_demo(workshop_name):
198
+ demo_name = "Demo-Workshop-"+workshop_name
199
+ URL = "WORKSHOP"
200
+ get_WORM_demo(demo_name, URL)
201
+
202
+ def delete_all_demos():
203
+ path = os.getcwd()
204
+ pattern = os.path.join(path, "Demo-*")
205
+
206
+ for item in glob(pattern):
207
+ if not os.path.isdir(item):
208
+ continue
209
+ rmtree(item)
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: worm-library
3
+ Version: 1.0.0
4
+ Summary: Download WORM Portal tutorial notebooks and demo files
5
+ Author: Grayson Boyer
6
+ Author-email: Grayson Boyer <gmboyer@asu.edu>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/worm-portal/WORM-Library
9
+ Project-URL: Repository, https://github.com/worm-portal/WORM-Library
10
+ Project-URL: Documentation, https://github.com/worm-portal/WORM-Library
11
+ Project-URL: Issues, https://github.com/worm-portal/WORM-Library/issues
12
+ Keywords: geochemistry,thermodynamics,aqueous,speciation,tutorials
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: requests
25
+ Requires-Dist: beautifulsoup4
26
+ Requires-Dist: lxml
27
+ Dynamic: author
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ # worm-library
32
+
33
+ Download WORM Portal tutorial notebooks and demo files to your local environment.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install worm-library
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ import worm_library
45
+
46
+ # Download specific tutorials
47
+ worm_library.get_worm_tour() # WORM Tour introduction
48
+ worm_library.get_introduction_demo() # Basic introduction
49
+ worm_library.get_reaction_properties_demo() # Reaction properties tutorials
50
+ worm_library.get_univariant_curve_demo() # Univariant curves / geothermometry
51
+
52
+ # Aqueous speciation tutorials
53
+ worm_library.get_intro_aqueous_speciation_demo()
54
+ worm_library.get_multi_aqueous_speciation_demo()
55
+ worm_library.get_charge_balance_demo()
56
+ worm_library.get_heterogeneous_equilibrium_demo()
57
+ worm_library.get_heterogeneous_equilibrium_gas_demo()
58
+ worm_library.get_alter_suppress_demo()
59
+ worm_library.get_custom_data0_demo()
60
+ worm_library.get_EQ3_demo()
61
+ worm_library.get_EQ6_demo()
62
+
63
+ # Mass transfer tutorials
64
+ worm_library.get_intro_mass_transfer_demo()
65
+ worm_library.get_mass_transfer_feature_demo()
66
+ worm_library.get_mixing_demo()
67
+
68
+ # Additional tutorials
69
+ worm_library.get_speciation_datasets_demo()
70
+ worm_library.get_energy_supply_demo()
71
+
72
+ # Thermodynamic property estimation
73
+ worm_library.get_intro_aqorg_demo()
74
+ worm_library.get_aqorg_feature_demo()
75
+ worm_library.get_complicator_demo()
76
+ worm_library.get_estimate_HKF_demo()
77
+
78
+ # Community notebooks
79
+ worm_library.get_Weeks_2025_demo()
80
+ worm_library.get_Trinh_2026_demo()
81
+ worm_library.get_whats_in_water_demo()
82
+
83
+ # Workshop materials
84
+ worm_library.get_workshop_demo("workshop_name")
85
+
86
+ # Clean up all downloaded demos
87
+ worm_library.delete_all_demos()
88
+ ```
89
+
90
+ Each function downloads the relevant notebooks and data files to a `Demo-*` folder in your current working directory.
91
+
92
+ ## Links
93
+
94
+ - [WORM Portal](https://worm-portal.asu.edu/)
95
+ - [Full Tutorial Library on GitHub](https://github.com/worm-portal/WORM-Library)
96
+
97
+ ## License
98
+
99
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,7 @@
1
+ worm_library/__init__.py,sha256=_-kYeSQ1U_mxQa5qt5-XqN9faFA-gQpbYvkmmimHMxc,807
2
+ worm_library/downloader.py,sha256=TSbQT8GXptGGyOUm0kGeKq6JFQ5HTLoE3mbx6ykBi6w,7335
3
+ worm_library-1.0.0.dist-info/licenses/LICENSE,sha256=JK_A4G5aAIFRHGcr4_-iHwjKObIKl-3SlbsoSuOxJR4,1091
4
+ worm_library-1.0.0.dist-info/METADATA,sha256=zrVCvsghtOZoHYXMSJEUcN7sRgoDGld8fx8eLEie9qk,3246
5
+ worm_library-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ worm_library-1.0.0.dist-info/top_level.txt,sha256=MWPGe6LvBg-ELwW80C0z3wLqSMRftTIukZMLcOZs084,13
7
+ worm_library-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Grayson Boyer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ worm_library