milwaukee-mmsd-parser 0.1.2__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.
File without changes
@@ -0,0 +1,59 @@
1
+ import asyncio
2
+ import logging
3
+ from dataclasses import dataclass
4
+ from typing import List
5
+
6
+ import aiohttp
7
+ from bs4 import BeautifulSoup
8
+
9
+
10
+ @dataclass
11
+ class MMSDFacilityInformation:
12
+ name: str
13
+ current_million_gallons: int | None
14
+ maximum_million_gallons: int | None
15
+
16
+
17
+ async def get_facilities() -> List[MMSDFacilityInformation]:
18
+ async with aiohttp.ClientSession() as session:
19
+ async with session.get("https://www.mmsd.com/about-us/milwaukee-rain-facility-information") as response:
20
+ response.raise_for_status()
21
+ html = await response.text()
22
+
23
+ outputs = []
24
+ parsed = BeautifulSoup(html, features="html.parser")
25
+
26
+ for element in parsed.find_all("div", class_="tunnel-info"):
27
+ try:
28
+ current_storage_element = element.find("input", dict(name="current-storage"))
29
+ current_storage_gallons = try_parse_int(current_storage_element.get("value"))
30
+ max_capacity_element = element.find("input", dict(name="max-capacity"))
31
+ maximum_storage_gallons = try_parse_int(max_capacity_element.get("value"))
32
+ parent_element = element.parent
33
+ name_heading = parent_element.find("h4")
34
+ information = MMSDFacilityInformation(
35
+ name=name_heading.text.title(),
36
+ current_million_gallons=current_storage_gallons,
37
+ maximum_million_gallons=maximum_storage_gallons)
38
+ outputs.append(information)
39
+ except Exception:
40
+ logging.info("Failed to find data for " + element.text)
41
+
42
+ return outputs
43
+
44
+
45
+ def try_parse_int(value, default=None) -> int | None:
46
+ try:
47
+ return int(value)
48
+ except (ValueError, TypeError):
49
+ return default
50
+
51
+
52
+ async def main():
53
+ facilities = await get_facilities()
54
+ print(facilities)
55
+
56
+
57
+ if __name__ == "__main__":
58
+ logging.basicConfig(level=logging.INFO)
59
+ asyncio.run(main())
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: milwaukee-mmsd-parser
3
+ Version: 0.1.2
4
+ Summary: Parses MMSD current statuses, including Deep Tunnel and water treatement plant capacities
5
+ Author-email: Jason Fry <your.email@example.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.txt
12
+ Requires-Dist: beautifulsoup4>=4.6.1
13
+ Requires-Dist: aiohttp>=3.6.0
14
+ Dynamic: license-file
15
+
16
+ # Milwaukee, Wisconsin Milwaukee Metropolitan Sewerage District Parser
17
+
18
+ Parses MMSD current statuses, including Deep Tunnel and water treatement plant capacities
19
+
20
+ ### Installation
21
+
22
+ `python3 -m venv .venv`
23
+
24
+ `source .venv/bin/activate`
25
+
26
+ `pip3 install .`
27
+
28
+ ### Run
29
+
30
+ `python mke_mmsd_parser.py`
31
+
32
+ ```
33
+ [MMSDFacilityInformation(name='Deep Tunnel', current_million_gallons=8, maximum_million_gallons=432), MMSDFacilityInformation(name='South Shore Water Reclamation Facility', current_million_gallons=61, maximum_million_gallons=150), MMSDFacilityInformation(name='Jones Island Water Reclamation Facility', current_million_gallons=63, maximum_million_gallons=330)]
34
+ ```
35
+
36
+ ### Publishing
37
+
38
+ Get API key from [PyPI](https://pypi.org/)
39
+
40
+ `source .venv/bin/activate`
41
+
42
+ `pip3 install setuptools twine`
43
+
44
+ `python3 setup.py sdist`
45
+
46
+ `twine upload dist/*`, using your API key
47
+
@@ -0,0 +1,7 @@
1
+ milwaukee_mmsd_parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ milwaukee_mmsd_parser/mke_mmsd_parser.py,sha256=itDR_tmdEYoQPR7wqZ4ZlHREaL4wgw9T-wF-UYiBmBg,1894
3
+ milwaukee_mmsd_parser-0.1.2.dist-info/licenses/LICENSE.txt,sha256=uhdaHOqqno-UQZKgwgn41RCi_i77n3j_tExHlHC6Euc,1058
4
+ milwaukee_mmsd_parser-0.1.2.dist-info/METADATA,sha256=5IBR145PL-FXnO7bSG5XvIOaZfNI4CyVJJjgsl0G9_s,1390
5
+ milwaukee_mmsd_parser-0.1.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
6
+ milwaukee_mmsd_parser-0.1.2.dist-info/top_level.txt,sha256=gd8J5dhGDdmxEC9PAFI9_ANbehkIB_SpxHJI3y71cW0,22
7
+ milwaukee_mmsd_parser-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,7 @@
1
+ Copyright 2026 jasonfry89
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ milwaukee_mmsd_parser