uk_bin_collection 0.75.0__py3-none-any.whl → 0.76.0__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.
@@ -8,7 +8,19 @@ def get_councils_from_files(branch):
8
8
  url = f"https://api.github.com/repos/robbrad/UKBinCollectionData/contents/uk_bin_collection/uk_bin_collection/councils?ref={branch}"
9
9
  response = requests.get(url)
10
10
  data = response.json()
11
- return [item['name'].replace('.py', '') for item in data if item['name'].endswith('.py')]
11
+
12
+ # Debugging lines to check the response content and type
13
+ print(f"Response Status Code: {response.status_code}")
14
+ print(f"Response Content: {response.content}")
15
+ print(f"Parsed JSON Data: {data}")
16
+ print(f"Data Type: {type(data)}")
17
+
18
+ # Ensure 'data' is a list before proceeding
19
+ if isinstance(data, list):
20
+ return [item['name'].replace('.py', '') for item in data if item['name'].endswith('.py')]
21
+ else:
22
+ raise ValueError("Expected a list from the JSON response but got something else.")
23
+
12
24
 
13
25
  def get_councils_from_json(branch):
14
26
  url = f"https://raw.githubusercontent.com/robbrad/UKBinCollectionData/{branch}/uk_bin_collection/tests/input.json"
@@ -13,9 +13,7 @@ class CouncilClass(AbstractGetBinDataClass):
13
13
  data = {"bins": []}
14
14
  user_uprn = kwargs.get("uprn")
15
15
 
16
- api_url = (
17
- f"https://maps.westsuffolk.gov.uk/MyWestSuffolk.aspx?action=SetAddress&UniqueId={user_uprn}"
18
- )
16
+ api_url = f"https://maps.westsuffolk.gov.uk/MyWestSuffolk.aspx?action=SetAddress&UniqueId={user_uprn}"
19
17
 
20
18
  response = requests.get(api_url)
21
19
 
@@ -33,7 +31,9 @@ class CouncilClass(AbstractGetBinDataClass):
33
31
  if tag_class is None:
34
32
  return False
35
33
 
36
- parent_has_header = cur_tag.parent.find_all("h4", string="Bin collection days")
34
+ parent_has_header = cur_tag.parent.find_all(
35
+ "h4", string="Bin collection days"
36
+ )
37
37
  if len(parent_has_header) < 1:
38
38
  return False
39
39
 
@@ -46,19 +46,32 @@ class CouncilClass(AbstractGetBinDataClass):
46
46
  text_list = list(tag.stripped_strings)
47
47
  # Create and parse the list as tuples of name:date
48
48
  for bin_name, collection_date in itertools.batched(text_list, 2):
49
- # Clean-up the bin_name
50
- bin_name_clean = bin_name.strip().replace("\r", "").replace("\n", "")
51
- bin_name_clean = re.sub(' +', ' ', bin_name_clean)
52
-
53
- # Parse the date
54
- next_collection = date_parse(collection_date)
55
- next_collection = next_collection.replace(year=datetime.now().year)
56
-
57
- dict_data = {
58
- "type": bin_name_clean,
59
- "collectionDate": next_collection.strftime(date_format),
60
- }
61
-
62
- data["bins"].append(dict_data)
49
+ try:
50
+ # Clean-up the bin_name
51
+ bin_name_clean = (
52
+ bin_name.strip()
53
+ .replace("\r", "")
54
+ .replace("\n", "")
55
+ .replace(":", "")
56
+ )
57
+ bin_name_clean = re.sub(" +", " ", bin_name_clean)
58
+
59
+ # Get the bin colour
60
+ bin_colour = "".join(re.findall(r"^(.*) ", bin_name_clean))
61
+
62
+ # Parse the date
63
+ next_collection = date_parse(collection_date)
64
+ next_collection = next_collection.replace(year=datetime.now().year)
65
+
66
+ dict_data = {
67
+ "type": bin_name_clean,
68
+ "colour": bin_colour,
69
+ "collectionDate": next_collection.strftime(date_format),
70
+ }
71
+
72
+ data["bins"].append(dict_data)
73
+
74
+ except Exception as ex:
75
+ raise ValueError(f"Error parsing bin data: {ex}")
63
76
 
64
77
  return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.75.0
3
+ Version: 0.76.0
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -1,5 +1,5 @@
1
1
  uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- uk_bin_collection/tests/council_feature_input_parity.py,sha256=qS3JuQD__NomFiVvA0_xHL_kWRuvvRhLj_M30xUzcbg,3072
2
+ uk_bin_collection/tests/council_feature_input_parity.py,sha256=66MrXc-3SnkricUV7LyAs9GFux7wEH31xcs9xbdB5Qo,3515
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=XIYnckDPBwBd7jTX2CN7Nv4mhUQsiJYOnYzvXVGfpdk,16246
5
5
  uk_bin_collection/tests/input.json,sha256=lbJZCvGd0kvIvI-0dD7Q9clMnkk_zX2UWbp8j2Ji1ow,53474
@@ -155,7 +155,7 @@ uk_bin_collection/uk_bin_collection/councils/WestBerkshireCouncil.py,sha256=r90A
155
155
  uk_bin_collection/uk_bin_collection/councils/WestLindseyDistrictCouncil.py,sha256=JFWUy4w0CKulGq16PfbRDKAdQEbokVEuabwlZYigdEU,4606
156
156
  uk_bin_collection/uk_bin_collection/councils/WestLothianCouncil.py,sha256=dq0jimtARvRkZiGbVFrXXZgY-BODtz3uYZ5UKn0bf64,4114
157
157
  uk_bin_collection/uk_bin_collection/councils/WestNorthamptonshireCouncil.py,sha256=F1GeJUGND4DN_HuM6N0Elpeb0DAMm9_KeqG6qtIgZf4,1079
158
- uk_bin_collection/uk_bin_collection/councils/WestSuffolkCouncil.py,sha256=06GdKwfpbyJ0me3S6WGtAjG0bmdEuH6IupqSnu5xDYM,2143
158
+ uk_bin_collection/uk_bin_collection/councils/WestSuffolkCouncil.py,sha256=HMFWxM7VMhBuC7iubNGbZYEoCVWi--gRHDJMVdPPFOM,2633
159
159
  uk_bin_collection/uk_bin_collection/councils/WiganBoroughCouncil.py,sha256=YEbpbjkparhah4ahl6WZzI0mMHNrbKzdC6kA5gDQCUA,3745
160
160
  uk_bin_collection/uk_bin_collection/councils/WiltshireCouncil.py,sha256=it2Oh5Kmq3lD30gAZgk2bzZPNCtJcFHyQO1NgOQtfvU,5653
161
161
  uk_bin_collection/uk_bin_collection/councils/WindsorAndMaidenheadCouncil.py,sha256=triYeI4IIHF6_XMokF6BGAZkx_lPAXeGyuS9DEr5UxY,5553
@@ -164,8 +164,8 @@ uk_bin_collection/uk_bin_collection/councils/WyreCouncil.py,sha256=zDDa7n4K_zm5P
164
164
  uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bIdsvmoSzBjJAvTTi6yPfJa8xjJx1ys2w,1490
165
165
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
166
166
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=9qppF2oPkhmOoK8-ZkRIU1M6vhBh-yUCWAZEEd07iLk,5414
167
- uk_bin_collection-0.75.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
168
- uk_bin_collection-0.75.0.dist-info/METADATA,sha256=b_0s8wb3G7mz-D7aJGldKJYhveWr_59wZDTP-DXbplw,12594
169
- uk_bin_collection-0.75.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
170
- uk_bin_collection-0.75.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
171
- uk_bin_collection-0.75.0.dist-info/RECORD,,
167
+ uk_bin_collection-0.76.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
168
+ uk_bin_collection-0.76.0.dist-info/METADATA,sha256=fPVuZ8P3q1gKfuv1H9OEOUlFRxRWSuJmAWNXCaCZQfs,12594
169
+ uk_bin_collection-0.76.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
170
+ uk_bin_collection-0.76.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
171
+ uk_bin_collection-0.76.0.dist-info/RECORD,,