uk_bin_collection 0.77.0__py3-none-any.whl → 0.79.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.
- uk_bin_collection/tests/council_feature_input_parity.py +38 -57
- uk_bin_collection/tests/features/validate_council_outputs.feature +5 -770
- uk_bin_collection/tests/input.json +70 -1
- uk_bin_collection/tests/step_defs/test_validate_council.py +44 -16
- uk_bin_collection/tests/test_common_functions.py +4 -2
- uk_bin_collection/uk_bin_collection/common.py +4 -1
- uk_bin_collection/uk_bin_collection/councils/ChichesterDistrictCouncil.py +110 -0
- uk_bin_collection/uk_bin_collection/councils/DartfordBoroughCouncil.py +44 -0
- uk_bin_collection/uk_bin_collection/councils/DoverDistrictCouncil.py +11 -6
- uk_bin_collection/uk_bin_collection/councils/EppingForestDistrictCouncil.py +51 -0
- uk_bin_collection/uk_bin_collection/councils/FarehamBoroughCouncil.py +68 -0
- uk_bin_collection/uk_bin_collection/councils/HounslowCouncil.py +122 -0
- uk_bin_collection/uk_bin_collection/councils/KirkleesCouncil.py +3 -1
- uk_bin_collection/uk_bin_collection/councils/MoleValleyDistrictCouncil.py +13 -10
- uk_bin_collection/uk_bin_collection/councils/SouthKestevenDistrictCouncil.py +151 -0
- uk_bin_collection/uk_bin_collection/councils/StroudDistrictCouncil.py +94 -0
- uk_bin_collection/uk_bin_collection/councils/TendringDistrictCouncil.py +110 -0
- uk_bin_collection/uk_bin_collection/councils/WakefieldCityCouncil.py +3 -1
- uk_bin_collection/uk_bin_collection/councils/WalthamForest.py +127 -0
- uk_bin_collection/uk_bin_collection/create_new_council.py +51 -0
- {uk_bin_collection-0.77.0.dist-info → uk_bin_collection-0.79.0.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.77.0.dist-info → uk_bin_collection-0.79.0.dist-info}/RECORD +25 -15
- {uk_bin_collection-0.77.0.dist-info → uk_bin_collection-0.79.0.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.77.0.dist-info → uk_bin_collection-0.79.0.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.77.0.dist-info → uk_bin_collection-0.79.0.dist-info}/entry_points.txt +0 -0
@@ -1,27 +1,29 @@
|
|
1
1
|
import json
|
2
|
-
import re
|
3
2
|
import requests
|
4
3
|
import sys
|
5
4
|
from tabulate import tabulate
|
5
|
+
import base64
|
6
|
+
|
6
7
|
|
7
8
|
def get_councils_from_files(repo, branch):
|
8
9
|
url = f"https://api.github.com/repos/{repo}/contents/uk_bin_collection/uk_bin_collection/councils?ref={branch}"
|
9
10
|
print(f"Fetching councils from files at URL: {url}")
|
10
|
-
response = requests.get(url)
|
11
|
-
|
12
|
-
# Debugging lines to check the response content and type
|
13
|
-
print(f"Response Status Code (Files): {response.status_code}")
|
14
|
-
|
11
|
+
response = requests.get(url, headers={"Accept": "application/vnd.github.v3+json"})
|
12
|
+
|
15
13
|
if response.status_code == 200:
|
16
14
|
try:
|
17
15
|
data = response.json()
|
18
|
-
#print(f"Parsed JSON Data (Files): {data}")
|
19
|
-
# Ensure 'data' is a list before proceeding
|
20
16
|
if isinstance(data, list):
|
21
|
-
return [
|
17
|
+
return [
|
18
|
+
item["name"].replace(".py", "")
|
19
|
+
for item in data
|
20
|
+
if item["name"].endswith(".py")
|
21
|
+
]
|
22
22
|
else:
|
23
23
|
print("Expected a list from the JSON response but got something else.")
|
24
|
-
raise ValueError(
|
24
|
+
raise ValueError(
|
25
|
+
"Expected a list from the JSON response but got something else."
|
26
|
+
)
|
25
27
|
except json.JSONDecodeError as e:
|
26
28
|
print(f"JSON decoding error: {e}")
|
27
29
|
raise
|
@@ -29,18 +31,17 @@ def get_councils_from_files(repo, branch):
|
|
29
31
|
print(f"Failed to fetch councils from files: {response.content}")
|
30
32
|
return []
|
31
33
|
|
34
|
+
|
32
35
|
def get_councils_from_json(repo, branch):
|
33
|
-
url = f"https://
|
36
|
+
url = f"https://api.github.com/repos/{repo}/contents/uk_bin_collection/tests/input.json?ref={branch}"
|
34
37
|
print(f"Fetching councils from JSON at URL: {url}")
|
35
|
-
response = requests.get(url)
|
36
|
-
|
37
|
-
# Debugging lines to check the response content and type
|
38
|
-
print(f"Response Status Code (JSON): {response.status_code}")
|
39
|
-
|
38
|
+
response = requests.get(url, headers={"Accept": "application/vnd.github.v3+json"})
|
39
|
+
|
40
40
|
if response.status_code == 200:
|
41
41
|
try:
|
42
|
-
|
43
|
-
|
42
|
+
content = response.json().get("content", "")
|
43
|
+
content_decoded = base64.b64decode(content).decode("utf-8")
|
44
|
+
data = json.loads(content_decoded)
|
44
45
|
return list(data.keys())
|
45
46
|
except json.JSONDecodeError as e:
|
46
47
|
print(f"JSON decoding error: {e}")
|
@@ -49,72 +50,51 @@ def get_councils_from_json(repo, branch):
|
|
49
50
|
print(f"Failed to fetch councils from JSON: {response.content}")
|
50
51
|
return []
|
51
52
|
|
52
|
-
def get_councils_from_features(repo, branch):
|
53
|
-
url = f"https://raw.githubusercontent.com/{repo}/{branch}/uk_bin_collection/tests/features/validate_council_outputs.feature"
|
54
|
-
print(f"Fetching councils from features at URL: {url}")
|
55
|
-
response = requests.get(url)
|
56
|
-
|
57
|
-
# Debugging lines to check the response content and type
|
58
|
-
print(f"Response Status Code (Features): {response.status_code}")
|
59
|
-
|
60
|
-
if response.status_code == 200:
|
61
|
-
content = response.text
|
62
|
-
#print(f"Fetched Features Content: {content[:500]}...") # Print only the first 500 characters for brevity
|
63
|
-
return re.findall(r'Examples:\s+(\w+)', content)
|
64
|
-
else:
|
65
|
-
print(f"Failed to fetch councils from features: {response.content}")
|
66
|
-
return []
|
67
53
|
|
68
|
-
def compare_councils(councils1, councils2
|
54
|
+
def compare_councils(councils1, councils2):
|
69
55
|
set1 = set(councils1)
|
70
56
|
set2 = set(councils2)
|
71
|
-
|
72
|
-
all_councils = set1 | set2 | set3
|
57
|
+
all_councils = set1 | set2
|
73
58
|
all_council_data = {}
|
74
59
|
discrepancies_found = False
|
75
60
|
for council in all_councils:
|
76
61
|
in_files = council in set1
|
77
62
|
in_json = council in set2
|
78
|
-
|
79
|
-
discrepancies_count = [in_files, in_json, in_features].count(False)
|
63
|
+
discrepancies_count = [in_files, in_json].count(False)
|
80
64
|
all_council_data[council] = {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
'discrepancies_count': discrepancies_count
|
65
|
+
"in_files": in_files,
|
66
|
+
"in_json": in_json,
|
67
|
+
"discrepancies_count": discrepancies_count,
|
85
68
|
}
|
86
69
|
if discrepancies_count > 0:
|
87
70
|
discrepancies_found = True
|
88
71
|
return all_council_data, discrepancies_found
|
89
72
|
|
73
|
+
|
90
74
|
def main(repo="robbrad/UKBinCollectionData", branch="master"):
|
91
75
|
# Execute and print the comparison
|
92
76
|
print(f"Starting comparison for repo: {repo}, branch: {branch}")
|
93
77
|
file_councils = get_councils_from_files(repo, branch)
|
94
78
|
json_councils = get_councils_from_json(repo, branch)
|
95
|
-
feature_councils = get_councils_from_features(repo, branch)
|
96
79
|
|
97
|
-
|
98
|
-
|
99
|
-
|
80
|
+
all_councils_data, discrepancies_found = compare_councils(
|
81
|
+
file_councils, json_councils
|
82
|
+
)
|
100
83
|
|
101
|
-
all_councils_data, discrepancies_found = compare_councils(file_councils, json_councils, feature_councils)
|
102
|
-
|
103
|
-
# Create a list of lists for tabulate, sort by discrepancies count and then by name
|
104
84
|
table_data = []
|
105
|
-
headers = ["Council Name", "In Files", "In JSON", "
|
106
|
-
for council, presence in sorted(
|
85
|
+
headers = ["Council Name", "In Files", "In JSON", "Discrepancies"]
|
86
|
+
for council, presence in sorted(
|
87
|
+
all_councils_data.items(), key=lambda x: (x[1]["discrepancies_count"], x[0])
|
88
|
+
):
|
107
89
|
row = [
|
108
90
|
council,
|
109
|
-
"✔" if presence[
|
110
|
-
"✔" if presence[
|
111
|
-
|
112
|
-
presence['discrepancies_count']
|
91
|
+
"✔" if presence["in_files"] else "✘",
|
92
|
+
"✔" if presence["in_json"] else "✘",
|
93
|
+
presence["discrepancies_count"],
|
113
94
|
]
|
114
95
|
table_data.append(row)
|
115
96
|
|
116
|
-
|
117
|
-
print(tabulate(table_data, headers=headers, tablefmt='grid'))
|
97
|
+
print(tabulate(table_data, headers=headers, tablefmt="grid"))
|
118
98
|
|
119
99
|
if discrepancies_found:
|
120
100
|
print("Discrepancies found! Failing the workflow.")
|
@@ -122,6 +102,7 @@ def main(repo="robbrad/UKBinCollectionData", branch="master"):
|
|
122
102
|
else:
|
123
103
|
print("No discrepancies found. Workflow successful.")
|
124
104
|
|
105
|
+
|
125
106
|
if __name__ == "__main__":
|
126
107
|
repo = sys.argv[1] if len(sys.argv) > 1 else "robbrad/UKBinCollectionData"
|
127
108
|
branch = sys.argv[2] if len(sys.argv) > 2 else "master"
|