uk_bin_collection 0.146.0__py3-none-any.whl → 0.146.2__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/compare_lad_codes.py +58 -0
- uk_bin_collection/tests/input.json +2 -1
- uk_bin_collection/uk_bin_collection/councils/Hillingdon.py +53 -32
- {uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/METADATA +2 -1
- {uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/RECORD +8 -7
- {uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
import json
|
2
|
+
import geopandas as gpd
|
3
|
+
|
4
|
+
def extract_lad_codes(input_json_path):
|
5
|
+
with open(input_json_path, "r") as f:
|
6
|
+
data = json.load(f)
|
7
|
+
|
8
|
+
lad_codes = set()
|
9
|
+
lad_code_to_council_input = {}
|
10
|
+
|
11
|
+
for council_key, council_info in data.items():
|
12
|
+
if isinstance(council_info, dict):
|
13
|
+
if "LAD24CD" in council_info:
|
14
|
+
code = council_info["LAD24CD"]
|
15
|
+
lad_codes.add(code)
|
16
|
+
lad_code_to_council_input[code] = council_key
|
17
|
+
if "supported_councils_LAD24CD" in council_info:
|
18
|
+
for code in council_info["supported_councils_LAD24CD"]:
|
19
|
+
lad_codes.add(code)
|
20
|
+
lad_code_to_council_input[code] = f"{council_key} (shared)"
|
21
|
+
|
22
|
+
return lad_codes, lad_code_to_council_input
|
23
|
+
|
24
|
+
def compare_with_geojson(input_lad_codes, geojson_path):
|
25
|
+
gdf = gpd.read_file(geojson_path)
|
26
|
+
geojson_lad_codes = set(gdf["LAD24CD"].dropna().unique())
|
27
|
+
|
28
|
+
geojson_lad_map = {
|
29
|
+
row["LAD24CD"]: row["LAD24NM"]
|
30
|
+
for _, row in gdf.iterrows()
|
31
|
+
if "LAD24CD" in row and "LAD24NM" in row
|
32
|
+
}
|
33
|
+
|
34
|
+
missing_in_input = geojson_lad_codes - input_lad_codes
|
35
|
+
extra_in_input = input_lad_codes - geojson_lad_codes
|
36
|
+
matching = input_lad_codes & geojson_lad_codes
|
37
|
+
|
38
|
+
return matching, missing_in_input, extra_in_input, geojson_lad_map
|
39
|
+
|
40
|
+
# --- Run the comparison ---
|
41
|
+
input_json_path = "uk_bin_collection/tests/input.json"
|
42
|
+
geojson_path = "uk_bin_collection/Local_Authority_Boundaries.geojson"
|
43
|
+
|
44
|
+
input_lad_codes, input_name_map = extract_lad_codes(input_json_path)
|
45
|
+
matching, missing, extra, geojson_name_map = compare_with_geojson(input_lad_codes, geojson_path)
|
46
|
+
|
47
|
+
# --- Print results ---
|
48
|
+
print(f"✅ Matching LAD24CDs ({len(matching)}):")
|
49
|
+
for code in sorted(matching):
|
50
|
+
print(f" {code} → input.json: {input_name_map.get(code)} | geojson: {geojson_name_map.get(code)}")
|
51
|
+
|
52
|
+
print(f"\n🟡 LADs in GeoJSON but missing in input.json ({len(missing)}):")
|
53
|
+
for code in sorted(missing):
|
54
|
+
print(f" {code} → geojson: {geojson_name_map.get(code)}")
|
55
|
+
|
56
|
+
print(f"\n🔴 LADs in input.json but not in GeoJSON ({len(extra)}):")
|
57
|
+
for code in sorted(extra):
|
58
|
+
print(f" {code} → input.json: {input_name_map.get(code)}")
|
@@ -35,41 +35,62 @@ DAYS_OF_WEEK = {
|
|
35
35
|
def get_bank_holiday_changes(driver: WebDriver) -> Dict[str, str]:
|
36
36
|
"""Fetch and parse bank holiday collection changes from the council website."""
|
37
37
|
bank_holiday_url = "https://www.hillingdon.gov.uk/bank-holiday-collections"
|
38
|
-
|
38
|
+
changes: Dict[str, str] = {}
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
wait.until(EC.presence_of_element_located((By.TAG_NAME, "table")))
|
40
|
+
try:
|
41
|
+
driver.get(bank_holiday_url)
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
# Check if the page is a 404 or has an error
|
44
|
+
if "404" in driver.title or "Page not found" in driver.page_source:
|
45
|
+
print("Bank holiday page not found (404).")
|
46
|
+
return changes
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
48
|
+
# Wait for page to load
|
49
|
+
wait = WebDriverWait(driver, 10)
|
50
|
+
try:
|
51
|
+
wait.until(EC.presence_of_element_located((By.TAG_NAME, "table")))
|
52
|
+
except TimeoutException:
|
53
|
+
print("No tables found on the bank holiday page.")
|
54
|
+
return changes
|
55
|
+
|
56
|
+
# Parse the page
|
57
|
+
soup = BeautifulSoup(driver.page_source, features="html.parser")
|
58
|
+
|
59
|
+
# Find all tables with collection changes
|
60
|
+
tables = soup.find_all("table")
|
61
|
+
if not tables:
|
62
|
+
print("No relevant tables found on the bank holiday page.")
|
63
|
+
return changes
|
64
|
+
|
65
|
+
for table in tables:
|
66
|
+
# Check if this is a collection changes table
|
67
|
+
headers = [th.text.strip() for th in table.find_all("th")]
|
68
|
+
if (
|
69
|
+
"Normal collection day" in headers
|
70
|
+
and "Revised collection day" in headers
|
71
|
+
):
|
72
|
+
# Process each row
|
73
|
+
for row in table.find_all("tr")[1:]: # Skip header row
|
74
|
+
cols = row.find_all("td")
|
75
|
+
if len(cols) >= 2:
|
76
|
+
normal_date = cols[0].text.strip()
|
77
|
+
revised_date = cols[1].text.strip()
|
78
|
+
|
79
|
+
# Parse dates
|
80
|
+
try:
|
81
|
+
normal_date = parse(normal_date, fuzzy=True).strftime(
|
82
|
+
"%d/%m/%Y"
|
83
|
+
)
|
84
|
+
revised_date = parse(revised_date, fuzzy=True).strftime(
|
85
|
+
"%d/%m/%Y"
|
86
|
+
)
|
87
|
+
changes[normal_date] = revised_date
|
88
|
+
except Exception as e:
|
89
|
+
print(f"Error parsing dates: {e}")
|
90
|
+
continue
|
91
|
+
|
92
|
+
except Exception as e:
|
93
|
+
print(f"An error occurred while fetching bank holiday changes: {e}")
|
73
94
|
|
74
95
|
return changes
|
75
96
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: uk_bin_collection
|
3
|
-
Version: 0.146.
|
3
|
+
Version: 0.146.2
|
4
4
|
Summary: Python Lib to collect UK Bin Data
|
5
5
|
Author: Robert Bradley
|
6
6
|
Author-email: robbrad182@gmail.com
|
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.12
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
11
11
|
Requires-Dist: bs4
|
12
|
+
Requires-Dist: geopandas (>=1.0.1,<2.0.0)
|
12
13
|
Requires-Dist: holidays
|
13
14
|
Requires-Dist: icalevents (>=0.2.1,<0.3.0)
|
14
15
|
Requires-Dist: lxml
|
@@ -1,11 +1,12 @@
|
|
1
1
|
uk_bin_collection/Local_Authority_Boundaries.geojson,sha256=_j-hUiL0--t2ewd_s29-j7_AKRlhagRMmOhXyco-B6I,1175922
|
2
2
|
uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
uk_bin_collection/compare_lad_codes.py,sha256=BjXPzxYbbqyl2Pv9yPip0BVpyD3GOofwgWa-BQUecqM,2214
|
3
4
|
uk_bin_collection/map.html,sha256=qKc4Lscv1eSIc0M3vDofzZf5w9_eslEYpz1-kK4tup0,4346
|
4
5
|
uk_bin_collection/tests/check_selenium_url_in_input.json.py,sha256=lf-JT7vvaSfvgbrfOhzrhfSzJqL82WajlRqo1GqfcMM,7875
|
5
6
|
uk_bin_collection/tests/council_feature_input_parity.py,sha256=DO6Mk4ImYgM5ZCZ-cutwz5RoYYWZRLYx2tr6zIs_9Rc,3843
|
6
7
|
uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
|
7
8
|
uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=SJK-Vc737hrf03tssxxbeg_JIvAH-ddB8f6gU1LTbuQ,251
|
8
|
-
uk_bin_collection/tests/input.json,sha256
|
9
|
+
uk_bin_collection/tests/input.json,sha256=-EVTLbgBwk879YMbAHkIYC7svXffzlL8xOa8Tab8M7g,133327
|
9
10
|
uk_bin_collection/tests/output.schema,sha256=ZwKQBwYyTDEM4G2hJwfLUVM-5v1vKRvRK9W9SS1sd18,1086
|
10
11
|
uk_bin_collection/tests/step_defs/step_helpers/file_handler.py,sha256=Ygzi4V0S1MIHqbdstUlIqtRIwnynvhu4UtpweJ6-5N8,1474
|
11
12
|
uk_bin_collection/tests/step_defs/test_validate_council.py,sha256=VZ0a81sioJULD7syAYHjvK_-nT_Rd36tUyzPetSA0gk,3475
|
@@ -148,7 +149,7 @@ uk_bin_collection/uk_bin_collection/councils/HerefordshireCouncil.py,sha256=JpQh
|
|
148
149
|
uk_bin_collection/uk_bin_collection/councils/HertsmereBoroughCouncil.py,sha256=ZbSsmqHStd2JtTMAq1Bhcvsj1BYp6ijELyOjZFX2GSw,6435
|
149
150
|
uk_bin_collection/uk_bin_collection/councils/HighPeakCouncil.py,sha256=x7dfy8mdt2iGl8qJxHb-uBh4u0knmi9MJ6irOJw9WYA,4805
|
150
151
|
uk_bin_collection/uk_bin_collection/councils/HighlandCouncil.py,sha256=GNxDU65QuZHV5va2IrKtcJ6TQoDdwmV03JvkVqOauP4,3291
|
151
|
-
uk_bin_collection/uk_bin_collection/councils/Hillingdon.py,sha256=
|
152
|
+
uk_bin_collection/uk_bin_collection/councils/Hillingdon.py,sha256=2OUp0iYO1YeZuTq0XRUalgoay5JRZgfHKKEwYzdMAU0,11291
|
152
153
|
uk_bin_collection/uk_bin_collection/councils/HinckleyandBosworthBoroughCouncil.py,sha256=51vXTKrstfJhb7cLCcrsvA9qKCsptyNMZvy7ML9DasM,2344
|
153
154
|
uk_bin_collection/uk_bin_collection/councils/HullCityCouncil.py,sha256=UHcesBoctFVcXDYuwfag43KbcJcopkEDzJ-54NxtK0Q,1851
|
154
155
|
uk_bin_collection/uk_bin_collection/councils/HuntingdonDistrictCouncil.py,sha256=dGyhhG6HRjQ2SPeiRwUPTGlk9dPIslagV2k0GjEOn1s,1587
|
@@ -332,8 +333,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
332
333
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=QD4v4xpsEE0QheR_fGaNOIRMc2FatcUfKkkhAhseyVU,1159
|
333
334
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
334
335
|
uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
|
335
|
-
uk_bin_collection-0.146.
|
336
|
-
uk_bin_collection-0.146.
|
337
|
-
uk_bin_collection-0.146.
|
338
|
-
uk_bin_collection-0.146.
|
339
|
-
uk_bin_collection-0.146.
|
336
|
+
uk_bin_collection-0.146.2.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
337
|
+
uk_bin_collection-0.146.2.dist-info/METADATA,sha256=1F2N9JtI_FSX2IALiojB8bO-kjCn1N2tNyAAnKGuv6s,19900
|
338
|
+
uk_bin_collection-0.146.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
339
|
+
uk_bin_collection-0.146.2.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
340
|
+
uk_bin_collection-0.146.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.146.0.dist-info → uk_bin_collection-0.146.2.dist-info}/entry_points.txt
RENAMED
File without changes
|