uk_bin_collection 0.123.1__py3-none-any.whl → 0.124.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+ }
@@ -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")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.123.1
3
+ Version: 0.124.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=bKqDUy2Db-A44Vz-Tc0a-xwRh6MIaSxbvbsgBP1Bw1U,111573
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
@@ -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.123.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
291
- uk_bin_collection-0.123.1.dist-info/METADATA,sha256=dYR-njpCJLv4wZ3xBqNhflxHImbG5ayGnDCHJz8l7Ho,17574
292
- uk_bin_collection-0.123.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
293
- uk_bin_collection-0.123.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
294
- uk_bin_collection-0.123.1.dist-info/RECORD,,
291
+ uk_bin_collection-0.124.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
292
+ uk_bin_collection-0.124.0.dist-info/METADATA,sha256=-6QLTEvvroL0aohw7uDWHyyh9dnDfMvdu5S4AtooxYw,17574
293
+ uk_bin_collection-0.124.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
294
+ uk_bin_collection-0.124.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
295
+ uk_bin_collection-0.124.0.dist-info/RECORD,,