uk_bin_collection 0.116.0__py3-none-any.whl → 0.117.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1448,6 +1448,12 @@
1448
1448
  "wiki_name": "South Ribble Council",
1449
1449
  "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
1450
1450
  },
1451
+ "SouthStaffordshireDistrictCouncil": {
1452
+ "uprn": "200004523954",
1453
+ "url": "https://www.sstaffs.gov.uk/where-i-live?uprn=200004523954",
1454
+ "wiki_name": "South Staffordshire District Council",
1455
+ "wiki_note": "The URL needs to be `https://www.sstaffs.gov.uk/where-i-live?uprn=<Your_UPRN>`. Replace `<Your_UPRN>` with your UPRN."
1456
+ },
1451
1457
  "SouthTynesideCouncil": {
1452
1458
  "house_number": "1",
1453
1459
  "postcode": "NE33 3JW",
@@ -0,0 +1,99 @@
1
+ from bs4 import BeautifulSoup
2
+
3
+ from uk_bin_collection.uk_bin_collection.common import *
4
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
5
+
6
+
7
+ # import the wonderful Beautiful Soup and the URL grabber
8
+ class CouncilClass(AbstractGetBinDataClass):
9
+ """
10
+ Concrete classes have to implement all abstract operations of the
11
+ base class. They can also override some operations with a default
12
+ implementation.
13
+ """
14
+
15
+ def parse_date(self, date_str):
16
+ months = {
17
+ "January": "01",
18
+ "February": "02",
19
+ "March": "03",
20
+ "April": "04",
21
+ "May": "05",
22
+ "June": "06",
23
+ "July": "07",
24
+ "August": "08",
25
+ "September": "09",
26
+ "October": "10",
27
+ "November": "11",
28
+ "December": "12",
29
+ }
30
+ day, date, month_abbr, year = date_str.split()
31
+ month = months[month_abbr]
32
+ return f"{date}/{month}/{year}"
33
+
34
+ def add_bin_types_to_collection(
35
+ self, bin_data: {"bins": []}, collection_date: str, collectionType: str
36
+ ):
37
+ if "Grey Bin" in collectionType:
38
+ bin_data["bins"].append(
39
+ {
40
+ "type": "Grey Bin",
41
+ "collectionDate": self.parse_date(collection_date),
42
+ }
43
+ )
44
+ if "Green Bin" in collectionType:
45
+ bin_data["bins"].append(
46
+ {
47
+ "type": "Green Bin",
48
+ "collectionDate": self.parse_date(collection_date),
49
+ }
50
+ )
51
+
52
+ if "Blue Bin" in collectionType:
53
+ bin_data["bins"].append(
54
+ {
55
+ "type": "Blue Bin",
56
+ "collectionDate": self.parse_date(collection_date),
57
+ }
58
+ )
59
+
60
+ def parse_data(self, page: str, **kwargs) -> dict:
61
+ # Make a BS4 object
62
+ soup = BeautifulSoup(page.text, features="html.parser")
63
+ soup.prettify()
64
+
65
+ # Initialize the bin data structure
66
+ bin_data = {"bins": []}
67
+
68
+ collectionDatesSection = soup.find("div", id="showCollectionDates")
69
+
70
+ # Find next date
71
+ collection_date = collectionDatesSection.find(
72
+ "p", class_="collection-date"
73
+ ).getText()
74
+
75
+ # convert to date
76
+ collection_type = collectionDatesSection.find(
77
+ "p", class_="collection-type"
78
+ ).getText()
79
+
80
+ self.add_bin_types_to_collection(bin_data, collection_date, collection_type)
81
+
82
+ # Find the table with collection dates
83
+ table = collectionDatesSection.find("table", class_="leisure-table")
84
+
85
+ # Extract the rows containing the bin collection information
86
+ rows = table.find_all("tr")
87
+
88
+ # Loop through the rows and extract bin data
89
+ for row in rows:
90
+ cells = row.find_all("td")
91
+ if len(cells) == 2:
92
+ collection_date = cells[1].get_text(strip=True)
93
+ collection_type = cells[0].get_text(strip=True)
94
+
95
+ self.add_bin_types_to_collection(
96
+ bin_data, collection_date, collection_type
97
+ )
98
+
99
+ return bin_data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.116.0
3
+ Version: 0.117.0
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -2,7 +2,7 @@ uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
2
2
  uk_bin_collection/tests/council_feature_input_parity.py,sha256=DO6Mk4ImYgM5ZCZ-cutwz5RoYYWZRLYx2tr6zIs_9Rc,3843
3
3
  uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
4
4
  uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=SJK-Vc737hrf03tssxxbeg_JIvAH-ddB8f6gU1LTbuQ,251
5
- uk_bin_collection/tests/input.json,sha256=YbcJwMyKLhZPNACJ8VL3QKjV47A3SQD5suyo4N9yfDc,101581
5
+ uk_bin_collection/tests/input.json,sha256=SYYyHZnd-yzGAz4ZLulu4DWjY4ykaCQ3zQgtkLdYVpg,101933
6
6
  uk_bin_collection/tests/output.schema,sha256=ZwKQBwYyTDEM4G2hJwfLUVM-5v1vKRvRK9W9SS1sd18,1086
7
7
  uk_bin_collection/tests/step_defs/step_helpers/file_handler.py,sha256=Ygzi4V0S1MIHqbdstUlIqtRIwnynvhu4UtpweJ6-5N8,1474
8
8
  uk_bin_collection/tests/step_defs/test_validate_council.py,sha256=VZ0a81sioJULD7syAYHjvK_-nT_Rd36tUyzPetSA0gk,3475
@@ -198,6 +198,7 @@ uk_bin_collection/uk_bin_collection/councils/SouthLanarkshireCouncil.py,sha256=f
198
198
  uk_bin_collection/uk_bin_collection/councils/SouthNorfolkCouncil.py,sha256=C2qIZjjbl9JnuukX9OH2RbfP0hSdp3uX76APGY33qKs,4622
199
199
  uk_bin_collection/uk_bin_collection/councils/SouthOxfordshireCouncil.py,sha256=zW4bN3hcqNoK_Y0-vPpuZs3K0LTPvApu6_v9K-D7WjE,3879
200
200
  uk_bin_collection/uk_bin_collection/councils/SouthRibbleCouncil.py,sha256=OdexbeiI5WsCfjlsnHjAce8oGF5fW-n7q2XOuxcpHzw,3604
201
+ uk_bin_collection/uk_bin_collection/councils/SouthStaffordshireDistrictCouncil.py,sha256=ACQMHWyamnj1ag3gNF-8Jhp-DKUok1GhFdnzH4nCzwU,3201
201
202
  uk_bin_collection/uk_bin_collection/councils/SouthTynesideCouncil.py,sha256=dxXGrJfg_fn2IPTBgq6Duwy0WY8GYLafMuisaCjOnbs,3426
202
203
  uk_bin_collection/uk_bin_collection/councils/SouthwarkCouncil.py,sha256=Z6JIbUt3yr4oG60n1At4AjPIGrs7Qzn_sDNY-TsS62E,4882
203
204
  uk_bin_collection/uk_bin_collection/councils/StAlbansCityAndDistrictCouncil.py,sha256=mPZz6Za6kTSkrfHnj0OfwtnpRYR1dKvxbuFEKnWsiL8,1451
@@ -258,8 +259,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
258
259
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
259
260
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
260
261
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
261
- uk_bin_collection-0.116.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
262
- uk_bin_collection-0.116.0.dist-info/METADATA,sha256=Dn9hGIlLa54AUUAhbw_fnO9kixM10sHL3cke0azYc3Y,17574
263
- uk_bin_collection-0.116.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
264
- uk_bin_collection-0.116.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
265
- uk_bin_collection-0.116.0.dist-info/RECORD,,
262
+ uk_bin_collection-0.117.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
263
+ uk_bin_collection-0.117.0.dist-info/METADATA,sha256=bK7wQJkZL4lfbMyqO3y-K75RtMP4EoojmrDqozltkC8,17574
264
+ uk_bin_collection-0.117.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
265
+ uk_bin_collection-0.117.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
266
+ uk_bin_collection-0.117.0.dist-info/RECORD,,