uk_bin_collection 0.82.0__py3-none-any.whl → 0.82.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.
@@ -283,10 +283,10 @@
283
283
  "wiki_name": "Doncaster Council"
284
284
  },
285
285
  "DorsetCouncil": {
286
- "url": "https://gi.dorsetcouncil.gov.uk/mapping/mylocal/viewresults/100040711049",
287
- "wiki_command_url_override": "https://gi.dorsetcouncil.gov.uk/mapping/mylocal/viewresults/XXXXXXXX",
288
- "wiki_name": "Dorset Council",
289
- "wiki_note": "Replace XXXXXXXX with UPRN."
286
+ "skip_get_url": true,
287
+ "url": "https://www.dorsetcouncil.gov.uk/",
288
+ "uprn": "100040711049",
289
+ "wiki_name": "Dorset Council"
290
290
  },
291
291
  "DoverDistrictCouncil": {
292
292
  "url": "https://collections.dover.gov.uk/property/100060908340",
@@ -14,38 +14,22 @@ class CouncilClass(AbstractGetBinDataClass):
14
14
  def parse_data(self, page: str, **kwargs) -> dict:
15
15
  data = {"bins": []}
16
16
  collections = []
17
-
18
- # Parse the page and find all the result boxes
19
- soup = BeautifulSoup(page.text, features="html.parser")
20
- soup.prettify()
21
- results = soup.find_all("li", {"class": "resultListItem"})
22
-
23
- # If the result box has a wanted string in, we can use it. Check the contents of each box and find the
24
- # desired text and dates
25
- for r in results:
26
- if "Your next" in r.text:
27
- if type(r.contents[10]) is element.NavigableString:
28
- bin_text = r.contents[10].text.split(" ")[2].title() + " bin"
29
- bin_date = datetime.strptime(
30
- remove_ordinal_indicator_from_date_string(
31
- r.contents[11].text.strip()
32
- ),
33
- "%A %d %B %Y",
34
- )
35
- else:
36
- bin_text = r.contents[11].text.split(" ")[2].title() + " bin"
37
- bin_date = datetime.strptime(
38
- remove_ordinal_indicator_from_date_string(
39
- r.contents[12].text.strip()
40
- ),
41
- "%A %d %B %Y",
42
- )
43
-
44
- if bin_date.date() >= datetime.now().date():
45
- collections.append((bin_text, bin_date))
46
-
47
- # Sort the text and date elements by date
48
- ordered_data = sorted(collections, key=lambda x: x[1])
17
+ url_base = "https://geoapi.dorsetcouncil.gov.uk/v1/services/"
18
+ url_types = ["recyclingday", "refuseday", "foodwasteday", "gardenwasteday"]
19
+
20
+ uprn = kwargs.get("uprn")
21
+ # Check the UPRN is valid
22
+ check_uprn(uprn)
23
+
24
+ for url_type in url_types:
25
+ response = requests.get(f"{url_base}{url_type}/{uprn}")
26
+ if response.status_code != 200:
27
+ raise ConnectionError(f"Could not fetch from {url_type} endpoint")
28
+ json_data = response.json()["values"][0]
29
+ collections.append((f"{json_data.get('type')} bin", datetime.strptime(json_data.get('dateNextVisit'), "%Y-%m-%d")))
30
+
31
+ # Sort the text and date elements by date
32
+ ordered_data = sorted(collections, key=lambda x: x[1])
49
33
 
50
34
  # Put the elements into the dictionary
51
35
  for item in ordered_data:
@@ -5,7 +5,7 @@ None
5
5
  """
6
6
 
7
7
  import json
8
- import logging
8
+ import logging, logging.config
9
9
  from abc import ABC, abstractmethod
10
10
  import os
11
11
  import requests
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.82.0
3
+ Version: 0.82.1
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=fI2ytw25uVQirZ28xuGL3iB7fPFJ9DrYwRn-s5ISce8,59301
5
+ uk_bin_collection/tests/input.json,sha256=R_hD1z-Wyc5VMuuQpBay7xLoo-ALHNSZX4OrLxOp_VQ,59163
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=LrOSt_loA1Mw3vTqaO2LpaDMu7rYJy6k5Kr-EOBln7s,3424
@@ -48,7 +48,7 @@ uk_bin_collection/uk_bin_collection/councils/CroydonCouncil.py,sha256=QJH27plySb
48
48
  uk_bin_collection/uk_bin_collection/councils/DartfordBoroughCouncil.py,sha256=SPirUUoweMwX5Txtsr0ocdcFtKxCQ9LhzTTJN20tM4w,1550
49
49
  uk_bin_collection/uk_bin_collection/councils/DerbyshireDalesDistrictCouncil.py,sha256=MQC1-jXezXczrxTcvPQvkpGgyyAbzSKlX38WsmftHak,4007
50
50
  uk_bin_collection/uk_bin_collection/councils/DoncasterCouncil.py,sha256=b7pxoToXu6dBBYXsXmlwfPXE8BjHxt0hjCOBNlNgvX8,3118
51
- uk_bin_collection/uk_bin_collection/councils/DorsetCouncil.py,sha256=sdSR5ryOSWHtK_0OKJ75LGOvMiUAnQCc3uwT3xfqZ_0,2304
51
+ uk_bin_collection/uk_bin_collection/councils/DorsetCouncil.py,sha256=zfXQJpywfEQvBOhv5uPSkHdTrAg114yXIuTYDjHSXsA,1629
52
52
  uk_bin_collection/uk_bin_collection/councils/DoverDistrictCouncil.py,sha256=3Zgap6kaVpDXtRfBKEL1Ms6eb0iFIipYKNtOq3Hrdd4,1891
53
53
  uk_bin_collection/uk_bin_collection/councils/DurhamCouncil.py,sha256=6O8bNsQVYQbrCYQE9Rp0c_rtkcXuxR3s9J6jn4MK4_s,1695
54
54
  uk_bin_collection/uk_bin_collection/councils/EastCambridgeshireCouncil.py,sha256=aYUVE5QqTxdj8FHhCB4EiFVDJahWJD9Pq0d1upBEvXg,1501
@@ -180,9 +180,9 @@ uk_bin_collection/uk_bin_collection/councils/WyreCouncil.py,sha256=zDDa7n4K_zm5P
180
180
  uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bIdsvmoSzBjJAvTTi6yPfJa8xjJx1ys2w,1490
181
181
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
182
182
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
183
- uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=MR3V6SlzeCTGkF7lB_mQgs7ATkbPUoQhVbF5ngs3xac,4529
184
- uk_bin_collection-0.82.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
185
- uk_bin_collection-0.82.0.dist-info/METADATA,sha256=zFhhom61NP92IdfPLs9hgFpFavReYfejQokftpu2Rzo,16231
186
- uk_bin_collection-0.82.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
187
- uk_bin_collection-0.82.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
188
- uk_bin_collection-0.82.0.dist-info/RECORD,,
183
+ uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
184
+ uk_bin_collection-0.82.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
185
+ uk_bin_collection-0.82.1.dist-info/METADATA,sha256=eF66OGftcUZmlsUAk4B5mGDaJrfHErD-tINXzxW6Ta8,16231
186
+ uk_bin_collection-0.82.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
187
+ uk_bin_collection-0.82.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
188
+ uk_bin_collection-0.82.1.dist-info/RECORD,,