uk_bin_collection 0.123.2__py3-none-any.whl → 0.124.1__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.
- uk_bin_collection/tests/input.json +8 -1
- uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py +21 -14
- uk_bin_collection/uk_bin_collection/councils/HartDistrictCouncil.py +67 -0
- {uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/RECORD +8 -7
- {uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/entry_points.txt +0 -0
@@ -840,6 +840,13 @@
|
|
840
840
|
"wiki_name": "Harrogate Borough Council",
|
841
841
|
"wiki_note": "Pass the UPRN, which can be found at [this site](https://secure.harrogate.gov.uk/inmyarea). URL doesn't need to be passed."
|
842
842
|
},
|
843
|
+
"HartDistrictCouncil": {
|
844
|
+
"skip_get_url": true,
|
845
|
+
"uprn": "100062349291",
|
846
|
+
"url": "https://www.hart.gov.uk/",
|
847
|
+
"wiki_name": "Hart District Council",
|
848
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
|
849
|
+
},
|
843
850
|
"HartlepoolBoroughCouncil": {
|
844
851
|
"url": "https://www.hartlepool.gov.uk",
|
845
852
|
"uprn": "100110019551",
|
@@ -2120,4 +2127,4 @@
|
|
2120
2127
|
"wiki_name": "York Council",
|
2121
2128
|
"wiki_note": "Provide your UPRN."
|
2122
2129
|
}
|
2123
|
-
}
|
2130
|
+
}
|
@@ -47,24 +47,31 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
47
47
|
# Process each row into a list of dictionaries
|
48
48
|
for row in rows[1:]: # Skip the header row
|
49
49
|
columns = row.find_all("td")
|
50
|
-
|
50
|
+
collection_date_text = (
|
51
51
|
columns[0].get_text(separator=" ").replace("\xa0", " ").strip()
|
52
52
|
)
|
53
53
|
service = columns[1].get_text(separator=" ").replace("\xa0", " ").strip()
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
# Safely try to parse collection date
|
56
|
+
if collection_date_text:
|
57
|
+
try:
|
58
|
+
collection_date = datetime.strptime(collection_date_text, "%a %d %b")
|
59
|
+
if collection_date.month == 1:
|
60
|
+
collection_date = collection_date.replace(year=current_year + 1)
|
61
|
+
else:
|
62
|
+
collection_date = collection_date.replace(year=current_year)
|
63
|
+
|
64
|
+
formatted_collection_date = collection_date.strftime("%d/%m/%Y") # Use your desired date format
|
65
|
+
dict_data = {
|
66
|
+
"type": service,
|
67
|
+
"collectionDate": formatted_collection_date,
|
68
|
+
}
|
69
|
+
bindata["bins"].append(dict_data)
|
70
|
+
except ValueError:
|
71
|
+
# Skip invalid collection_date
|
72
|
+
continue
|
73
|
+
|
74
|
+
# Sort valid bins by collectionDate
|
68
75
|
bindata["bins"].sort(
|
69
76
|
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
|
70
77
|
)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import json
|
2
|
+
from datetime import datetime
|
3
|
+
|
4
|
+
from bs4 import BeautifulSoup
|
5
|
+
|
6
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
7
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
8
|
+
|
9
|
+
|
10
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
11
|
+
class CouncilClass(AbstractGetBinDataClass):
|
12
|
+
"""
|
13
|
+
Concrete classes have to implement all abstract operations of the
|
14
|
+
base class. They can also override some operations with a default
|
15
|
+
implementation.
|
16
|
+
"""
|
17
|
+
|
18
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
19
|
+
|
20
|
+
user_uprn = kwargs.get("uprn")
|
21
|
+
check_uprn(user_uprn)
|
22
|
+
|
23
|
+
URI = f"https://www.hart.gov.uk/bbd-whitespace/next-collection-dates?uri=entity%3Anode%2F172&uprn={user_uprn}"
|
24
|
+
|
25
|
+
response = requests.get(URI)
|
26
|
+
response_table = response.json()
|
27
|
+
|
28
|
+
soup = BeautifulSoup(response_table[0]["data"], "html.parser")
|
29
|
+
# Make a BS4 object
|
30
|
+
# Find all the rows in the table
|
31
|
+
rows = soup.find_all("tr")
|
32
|
+
|
33
|
+
# Initialize an empty list to hold the bin data
|
34
|
+
bins = []
|
35
|
+
|
36
|
+
# Iterate through each row
|
37
|
+
for row in rows:
|
38
|
+
cells = row.find_all("td")
|
39
|
+
|
40
|
+
# Check if there are exactly 3 cells in the row
|
41
|
+
if len(cells) == 3:
|
42
|
+
bin_type = cells[0].get_text(strip=True)
|
43
|
+
collection_date = self.format_date(cells[2].get_text(strip=True))
|
44
|
+
|
45
|
+
# Create a dictionary for each bin and append to the bins list
|
46
|
+
bins.append({"type": bin_type, "collectionDate": collection_date})
|
47
|
+
|
48
|
+
return {"bins": bins}
|
49
|
+
|
50
|
+
def format_date(self, date_str):
|
51
|
+
# Get the current date and year
|
52
|
+
current_date = datetime.now()
|
53
|
+
current_year = current_date.year
|
54
|
+
|
55
|
+
# Parse the provided date string (e.g. "23 January")
|
56
|
+
date_obj = datetime.strptime(date_str, "%d %B")
|
57
|
+
|
58
|
+
# Check if the provided date has already passed this year
|
59
|
+
if date_obj.replace(year=current_year) < current_date:
|
60
|
+
# If the date has passed this year, assume the next year
|
61
|
+
date_obj = date_obj.replace(year=current_year + 1)
|
62
|
+
else:
|
63
|
+
# Otherwise, use the current year
|
64
|
+
date_obj = date_obj.replace(year=current_year)
|
65
|
+
|
66
|
+
# Format the date in "DD/MM/YYYY" format
|
67
|
+
return date_obj.strftime("%d/%m/%Y")
|
@@ -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=
|
5
|
+
uk_bin_collection/tests/input.json,sha256=tHHO48XXBiy9Hiu9g30fiYRtaFmF5LGAxxoUT2uMLT4,111879
|
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
|
@@ -46,7 +46,7 @@ uk_bin_collection/uk_bin_collection/councils/BrightonandHoveCityCouncil.py,sha25
|
|
46
46
|
uk_bin_collection/uk_bin_collection/councils/BristolCityCouncil.py,sha256=kJmmDJz_kQ45DHmG7ocrUpNJonEn0kuXYEDQyZaf9ks,5576
|
47
47
|
uk_bin_collection/uk_bin_collection/councils/BromleyBoroughCouncil.py,sha256=_bAFykZWZkEVUB-QKeVLfWO8plG6nRgn71QF2BUN2rk,4329
|
48
48
|
uk_bin_collection/uk_bin_collection/councils/BromsgroveDistrictCouncil.py,sha256=PUfxP8j5Oh9wFHkdjbrJzQli9UzMHZzwrZ2hkThrvhI,1781
|
49
|
-
uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py,sha256=
|
49
|
+
uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py,sha256=XCKjkypptrWE-pTkaWekDiZu9BCzDrDa-8he88BopMY,2852
|
50
50
|
uk_bin_collection/uk_bin_collection/councils/BroxtoweBoroughCouncil.py,sha256=-Facq-ToQkcWUePpKBwq90LZUFxgUSydNL2sYaLX4yw,4473
|
51
51
|
uk_bin_collection/uk_bin_collection/councils/BuckinghamshireCouncil.py,sha256=_ELVUM5VLp1nwDxRpvpsp6n8SzLJvp_UyMp-i_MXYuo,4383
|
52
52
|
uk_bin_collection/uk_bin_collection/councils/BurnleyBoroughCouncil.py,sha256=GJf1OPvUVj3vqsR3KjG0DFHZrSBu4ogIz_MJeVV8tNA,3192
|
@@ -118,6 +118,7 @@ uk_bin_collection/uk_bin_collection/councils/HaltonBoroughCouncil.py,sha256=gq_C
|
|
118
118
|
uk_bin_collection/uk_bin_collection/councils/HarboroughDistrictCouncil.py,sha256=uAbCgfrqkIkEKUyLVE8l72s5tzbfMFsw775i0nVRAyc,1934
|
119
119
|
uk_bin_collection/uk_bin_collection/councils/HaringeyCouncil.py,sha256=t_6AkAu4wrv8Q0WlDhWh_82I0djl5tk531Pzs-SjWzg,2647
|
120
120
|
uk_bin_collection/uk_bin_collection/councils/HarrogateBoroughCouncil.py,sha256=_g3fP5Nq-OUjgNrfRf4UEyFKzq0x8QK-4enh5RP1efA,2050
|
121
|
+
uk_bin_collection/uk_bin_collection/councils/HartDistrictCouncil.py,sha256=_llxT4JYYlwm20ZtS3fXwtDs6mwJyLTZBP2wBhvEpWk,2342
|
121
122
|
uk_bin_collection/uk_bin_collection/councils/HartlepoolBoroughCouncil.py,sha256=MUT1A24iZShT2p55rXEvgYwGUuw3W05Z4ZQAveehv-s,2842
|
122
123
|
uk_bin_collection/uk_bin_collection/councils/HertsmereBoroughCouncil.py,sha256=-ThSG6NIJP_wf2GmGL7SAvxbOujdhanZ8ECP4VSQCBs,5415
|
123
124
|
uk_bin_collection/uk_bin_collection/councils/HighPeakCouncil.py,sha256=x7dfy8mdt2iGl8qJxHb-uBh4u0knmi9MJ6irOJw9WYA,4805
|
@@ -287,8 +288,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
287
288
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
|
288
289
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
289
290
|
uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
|
290
|
-
uk_bin_collection-0.
|
291
|
-
uk_bin_collection-0.
|
292
|
-
uk_bin_collection-0.
|
293
|
-
uk_bin_collection-0.
|
294
|
-
uk_bin_collection-0.
|
291
|
+
uk_bin_collection-0.124.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
292
|
+
uk_bin_collection-0.124.1.dist-info/METADATA,sha256=DVW3dzxr43iFYTE0MbQ6dgetaVGpIFnqt47wPLFXw_U,17574
|
293
|
+
uk_bin_collection-0.124.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
294
|
+
uk_bin_collection-0.124.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
295
|
+
uk_bin_collection-0.124.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.123.2.dist-info → uk_bin_collection-0.124.1.dist-info}/entry_points.txt
RENAMED
File without changes
|