uk_bin_collection 0.98.5__py3-none-any.whl → 0.99.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.
@@ -620,6 +620,14 @@
620
620
  "wiki_name": "Lichfield District Council",
621
621
  "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
622
622
  },
623
+ "LincolnCouncil": {
624
+ "url": "https://lincoln.gov.uk",
625
+ "wiki_command_url_override": "https://lincoln.gov.uk",
626
+ "uprn": "000235024846",
627
+ "postcode": "LN5 7SH",
628
+ "wiki_name": "Tunbridge Wells Council",
629
+ "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
630
+ },
623
631
  "LisburnCastlereaghCityCouncil": {
624
632
  "house_number": "97",
625
633
  "postcode": "BT28 1JN",
@@ -871,6 +879,13 @@
871
879
  "wiki_name": "Oldham Council",
872
880
  "wiki_note": "Replace UPRN in URL with your own UPRN."
873
881
  },
882
+ "PerthAndKinrossCouncil": {
883
+ "url": "https://www.pkc.gov.uk",
884
+ "wiki_command_url_override": "https://www.pkc.gov.uk",
885
+ "uprn": "124032322",
886
+ "wiki_name": "Perth and Kinross Council",
887
+ "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
888
+ },
874
889
  "PortsmouthCityCouncil": {
875
890
  "postcode": "PO4 0LE",
876
891
  "skip_get_url": true,
@@ -1200,6 +1215,13 @@
1200
1215
  "url": "https://collections-torridge.azurewebsites.net/WebService2.asmx",
1201
1216
  "wiki_name": "Torridge District Council"
1202
1217
  },
1218
+ "TunbridgeWellsCouncil": {
1219
+ "url": "https://tunbridgewells.gov.uk",
1220
+ "wiki_command_url_override": "https://tunbridgewells.gov.uk",
1221
+ "uprn": "10090058289",
1222
+ "wiki_name": "Tunbridge Wells Council",
1223
+ "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
1224
+ },
1203
1225
  "UttlesfordDistrictCouncil": {
1204
1226
  "house_number": "72, Birchanger Lane",
1205
1227
  "postcode": "CM23 5QF",
@@ -0,0 +1,96 @@
1
+ import time
2
+
3
+ import requests
4
+
5
+ from uk_bin_collection.uk_bin_collection.common import *
6
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
7
+
8
+
9
+ # import the wonderful Beautiful Soup and the URL grabber
10
+ class CouncilClass(AbstractGetBinDataClass):
11
+ """
12
+ Concrete classes have to implement all abstract operations of the
13
+ base class. They can also override some operations with a default
14
+ implementation.
15
+ """
16
+
17
+ def parse_data(self, page: str, **kwargs) -> dict:
18
+
19
+ user_uprn = kwargs.get("uprn")
20
+ user_postcode = kwargs.get("postcode")
21
+ check_uprn(user_uprn)
22
+ check_postcode(user_postcode)
23
+ bindata = {"bins": []}
24
+
25
+ SESSION_URL = "https://contact.lincoln.gov.uk/authapi/isauthenticated?uri=https://contact.lincoln.gov.uk/AchieveForms/?mode=fill&consentMessage=yes&form_uri=sandbox-publish://AF-Process-503f9daf-4db9-4dd8-876a-6f2029f11196/AF-Stage-a1c0af0f-fec1-4419-80c0-0dd4e1d965c9/definition.json&process=1&process_uri=sandbox-processes://AF-Process-503f9daf-4db9-4dd8-876a-6f2029f11196&process_id=AF-Process-503f9daf-4db9-4dd8-876a-6f2029f11196&hostname=contact.lincoln.gov.uk&withCredentials=true"
26
+
27
+ API_URL = "https://contact.lincoln.gov.uk/apibroker/runLookup"
28
+
29
+ data = {
30
+ "formValues": {
31
+ "Section 1": {
32
+ "chooseaddress": {"value": user_uprn},
33
+ "postcode": {"value": user_postcode},
34
+ }
35
+ },
36
+ }
37
+
38
+ headers = {
39
+ "Content-Type": "application/json",
40
+ "Accept": "application/json",
41
+ "User-Agent": "Mozilla/5.0",
42
+ "X-Requested-With": "XMLHttpRequest",
43
+ "Referer": "https://contact.lincoln.gov.uk/fillform/?iframe_id=fillform-frame-1&db_id=",
44
+ }
45
+ s = requests.session()
46
+ r = s.get(SESSION_URL)
47
+ r.raise_for_status()
48
+ session_data = r.json()
49
+ sid = session_data["auth-session"]
50
+ params = {
51
+ "id": "62aafd258f72c",
52
+ "repeat_against": "",
53
+ "noRetry": "false",
54
+ "getOnlyTokens": "undefined",
55
+ "log_id": "",
56
+ "app_name": "AF-Renderer::Self",
57
+ # unix_timestamp
58
+ "_": str(int(time.time() * 1000)),
59
+ "sid": sid,
60
+ }
61
+
62
+ r = s.post(API_URL, json=data, headers=headers, params=params)
63
+ r.raise_for_status()
64
+ data = r.json()
65
+ rows_data = data["integration"]["transformed"]["rows_data"]
66
+ if not isinstance(rows_data, dict):
67
+ raise ValueError("Invalid data returned from API")
68
+
69
+ BIN_TYPES = [
70
+ ("refusenextdate", "Black Bin", "refuse_freq"),
71
+ ("recyclenextdate", "Brown Bin", "recycle_freq"),
72
+ ("gardennextdate", "Green Bin", "garden_freq"),
73
+ ]
74
+
75
+ for uprn, data in rows_data.items():
76
+ if uprn != user_uprn:
77
+ continue
78
+ for key, bin_type, freq in BIN_TYPES:
79
+ if not data[key]:
80
+ continue
81
+ offsets = [0]
82
+ if data[freq] == "fortnightly":
83
+ offsets.extend(list(range(14, 30, 14)))
84
+ elif data[freq] == "weekly":
85
+ offsets.extend(list(range(7, 30, 7)))
86
+ date = datetime.strptime(data[key], "%Y-%m-%d").date()
87
+ for offset in offsets:
88
+ dict_data = {
89
+ "type": bin_type,
90
+ "collectionDate": (date + timedelta(days=offset)).strftime(
91
+ "%d/%m/%Y"
92
+ ),
93
+ }
94
+ bindata["bins"].append(dict_data)
95
+
96
+ return bindata
@@ -0,0 +1,95 @@
1
+ import time
2
+
3
+ import requests
4
+
5
+ from uk_bin_collection.uk_bin_collection.common import *
6
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
7
+
8
+
9
+ # import the wonderful Beautiful Soup and the URL grabber
10
+ class CouncilClass(AbstractGetBinDataClass):
11
+ """
12
+ Concrete classes have to implement all abstract operations of the
13
+ base class. They can also override some operations with a default
14
+ implementation.
15
+ """
16
+
17
+ def parse_data(self, page: str, **kwargs) -> dict:
18
+
19
+ user_uprn = kwargs.get("uprn")
20
+ check_uprn(user_uprn)
21
+ bindata = {"bins": []}
22
+
23
+ SESSION_URL = "https://pkc-self.achieveservice.com/authapi/isauthenticated?uri=https%253A%252F%252Fpkc-self.achieveservice.com%252Fen%252FAchieveForms%252F%253Fform_uri%253Dsandbox-publish%253A%252F%252FAF-Process-de9223b1-a7c6-408f-aaa3-aee33fd7f7fa%252FAF-Stage-9fa33e2e-4c1b-4963-babf-4348ab8154bc%252Fdefinition.json%2526redirectlink%253D%25252Fen%2526cancelRedirectLink%253D%25252Fen%2526consentMessage%253Dyes&hostname=pkc-self.achieveservice.com&withCredentials=true"
24
+
25
+ API_URL = "https://pkc-self.achieveservice.com/apibroker/runLookup"
26
+
27
+ data = {
28
+ "formValues": {
29
+ "Bin collections": {"propertyUPRNQuery": {"value": user_uprn}}
30
+ },
31
+ }
32
+
33
+ headers = {
34
+ "Content-Type": "application/json",
35
+ "Accept": "application/json",
36
+ "User-Agent": "Mozilla/5.0",
37
+ "X-Requested-With": "XMLHttpRequest",
38
+ "Referer": "https://pkc-self.achieveservice.com/fillform/?iframe_id=fillform-frame-1&db_id=",
39
+ }
40
+ s = requests.session()
41
+ r = s.get(SESSION_URL)
42
+ r.raise_for_status()
43
+ session_data = r.json()
44
+ sid = session_data["auth-session"]
45
+ params = {
46
+ "id": "5c9267cee5efe",
47
+ "repeat_against": "",
48
+ "noRetry": "true",
49
+ "getOnlyTokens": "undefined",
50
+ "log_id": "",
51
+ "app_name": "AF-Renderer::Self",
52
+ # unix_timestamp
53
+ "_": str(int(time.time() * 1000)),
54
+ "sid": sid,
55
+ }
56
+
57
+ r = s.post(API_URL, json=data, headers=headers, params=params)
58
+ r.raise_for_status()
59
+
60
+ data = r.json()
61
+ rows_data = data["integration"]["transformed"]["rows_data"]["0"]
62
+ if not isinstance(rows_data, dict):
63
+ raise ValueError("Invalid data returned from API")
64
+
65
+ schedule = {
66
+ "Green Bin": [
67
+ rows_data.get("nextGeneralWasteCollectionDate"),
68
+ rows_data.get("nextGeneralWasteCollectionDate2nd"),
69
+ ],
70
+ "Blue Bin": [
71
+ rows_data.get("nextBlueCollectionDate"),
72
+ rows_data.get("nextBlueWasteCollectionDate2nd"),
73
+ ],
74
+ "Grey Bin": [
75
+ rows_data.get("nextGreyWasteCollectionDate"),
76
+ rows_data.get("nextGreyWasteCollectionDate2nd"),
77
+ ],
78
+ "Brown Bin": [
79
+ rows_data.get("nextGardenandFoodWasteCollectionDate"),
80
+ rows_data.get("nextGardenandFoodWasteCollectionDate2nd"),
81
+ ],
82
+ "Paper Waste": [
83
+ rows_data.get("nextPaperWasteCollectionDate"),
84
+ rows_data.get("nextPaperWasteCollectionDate2nd"),
85
+ ],
86
+ }
87
+
88
+ # Format and output the schedule
89
+ for bin_type, dates in schedule.items():
90
+ if any(dates):
91
+ for date in dates:
92
+ dict_data = {"type": bin_type, "collectionDate": date}
93
+ bindata["bins"].append(dict_data)
94
+
95
+ return bindata
@@ -0,0 +1,71 @@
1
+ import time
2
+
3
+ import requests
4
+
5
+ from uk_bin_collection.uk_bin_collection.common import *
6
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
7
+
8
+
9
+ # import the wonderful Beautiful Soup and the URL grabber
10
+ class CouncilClass(AbstractGetBinDataClass):
11
+ """
12
+ Concrete classes have to implement all abstract operations of the
13
+ base class. They can also override some operations with a default
14
+ implementation.
15
+ """
16
+
17
+ def parse_data(self, page: str, **kwargs) -> dict:
18
+
19
+ user_uprn = kwargs.get("uprn")
20
+ check_uprn(user_uprn)
21
+ bindata = {"bins": []}
22
+
23
+ SESSION_URL = "https://mytwbc.tunbridgewells.gov.uk/authapi/isauthenticated?uri=https%3A%2F%2Fmytwbc.tunbridgewells.gov.uk%2FAchieveForms%2F%3Fmode%3Dfill%26consentMessage%3Dyes%26form_uri%3Dsandbox-publish%3A%2F%2FAF-Process-e01af4d4-eb0f-4cfe-a5ac-c47b63f017ed%2FAF-Stage-88caf66c-378f-4082-ad1d-07b7a850af38%2Fdefinition.json%26process%3D1%26process_uri%3Dsandbox-processes%3A%2F%2FAF-Process-e01af4d4-eb0f-4cfe-a5ac-c47b63f017ed%26process_id%3DAF-Process-e01af4d4-eb0f-4cfe-a5ac-c47b63f017ed&hostname=mytwbc.tunbridgewells.gov.uk&withCredentials=true"
24
+
25
+ API_URL = "https://mytwbc.tunbridgewells.gov.uk/apibroker/runLookup"
26
+
27
+ data = {
28
+ "formValues": {"Property": {"siteReference": {"value": user_uprn}}},
29
+ }
30
+
31
+ headers = {
32
+ "Content-Type": "application/json",
33
+ "Accept": "application/json",
34
+ "User-Agent": "Mozilla/5.0",
35
+ "X-Requested-With": "XMLHttpRequest",
36
+ "Referer": "https://mytwbc.tunbridgewells.gov.uk/fillform/?iframe_id=fillform-frame-1&db_id=",
37
+ }
38
+ s = requests.session()
39
+ r = s.get(SESSION_URL)
40
+ r.raise_for_status()
41
+ session_data = r.json()
42
+ sid = session_data["auth-session"]
43
+ params = {
44
+ "id": "6314720683f30",
45
+ "repeat_against": "",
46
+ "noRetry": "false",
47
+ "getOnlyTokens": "undefined",
48
+ "log_id": "",
49
+ "app_name": "AF-Renderer::Self",
50
+ # unix_timestamp
51
+ "_": str(int(time.time() * 1000)),
52
+ "sid": sid,
53
+ }
54
+
55
+ r = s.post(API_URL, json=data, headers=headers, params=params)
56
+ r.raise_for_status()
57
+
58
+ data = r.json()
59
+ rows_data = data["integration"]["transformed"]["rows_data"]
60
+ if not isinstance(rows_data, dict):
61
+ raise ValueError("Invalid data returned from API")
62
+
63
+ for _, item in rows_data.items():
64
+ bin_type = item["collectionType"]
65
+ date = datetime.strptime(item["nextDateUnformatted"], "%d/%m/%Y").strftime(
66
+ "%d/%m/%Y"
67
+ )
68
+ dict_data = {"type": bin_type, "collectionDate": date}
69
+ bindata["bins"].append(dict_data)
70
+
71
+ return bindata
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.98.5
3
+ Version: 0.99.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=gkqIfeMzQQC76jc6J4DPRn1ZCp6AVdPU_7ra3gb7pyc,68114
5
+ uk_bin_collection/tests/input.json,sha256=MyICwD7_JIC5MIoyHk9kUItaHIxkPHuWdG85bsAiI4g,69171
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
@@ -96,6 +96,7 @@ uk_bin_collection/uk_bin_collection/councils/KnowsleyMBCouncil.py,sha256=VdlWDES
96
96
  uk_bin_collection/uk_bin_collection/councils/LancasterCityCouncil.py,sha256=FmHT6oyD4BwWuhxA80PHnGA7HPrLuyjP_54Cg8hT6k4,2537
97
97
  uk_bin_collection/uk_bin_collection/councils/LeedsCityCouncil.py,sha256=iSZApZ9oSfSatQ6dAxmykSfti91jGuY6n2BwEkVMOiU,5144
98
98
  uk_bin_collection/uk_bin_collection/councils/LichfieldDistrictCouncil.py,sha256=l3zgTWuKOW8fgb8PmXv0OTI6HaiGBPndefNQk8MM4oY,1810
99
+ uk_bin_collection/uk_bin_collection/councils/LincolnCouncil.py,sha256=aUCqjHuk0sLtx83a-2agcLIMgEbfqjltXRCBRXT9J-8,3733
99
100
  uk_bin_collection/uk_bin_collection/councils/LisburnCastlereaghCityCouncil.py,sha256=vSOzdEwp9ZeUhed7E3eVv9ReD-2XgbSkpyAbVnfc-Gk,3309
100
101
  uk_bin_collection/uk_bin_collection/councils/LiverpoolCityCouncil.py,sha256=n17OqZrCGrPrnxGUfHc-RGkb4oJ9Bx6uUWiLdzxfQlY,2587
101
102
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughEaling.py,sha256=QDx2Izr-6hUSFMi4UWqsgo3p6U8aRZ9d_Cu9cBSp2rY,1653
@@ -133,6 +134,7 @@ uk_bin_collection/uk_bin_collection/councils/NorthYorkshire.py,sha256=2wTrr3VrZD
133
134
  uk_bin_collection/uk_bin_collection/councils/NorthumberlandCouncil.py,sha256=KEFsxEvQ159fkuFo-fza67YCnnCZ5ElwE80zTrqDEWI,4990
134
135
  uk_bin_collection/uk_bin_collection/councils/NottinghamCityCouncil.py,sha256=panTCjnsBOQ98-TBO9xVZk_jcT_gjMhx3Gg5oWxBRLo,1254
135
136
  uk_bin_collection/uk_bin_collection/councils/OldhamCouncil.py,sha256=9dlesCxNoVXlmQaqZj7QFh00smnJbm1Gnjkr_Uvzurs,1771
137
+ uk_bin_collection/uk_bin_collection/councils/PerthAndKinrossCouncil.py,sha256=Kos5GzN2co3Ij3tSHOXB9S71Yt78RROCfVRtnh7M1VU,3657
136
138
  uk_bin_collection/uk_bin_collection/councils/PortsmouthCityCouncil.py,sha256=xogNgVvwM5FljCziiNLgZ_wzkOnrQkifi1dkPMDRMtg,5588
137
139
  uk_bin_collection/uk_bin_collection/councils/PrestonCityCouncil.py,sha256=3Nuin2hQsiEsbJR_kHldtzRhzmnPFctH7C7MFG7thj8,3838
138
140
  uk_bin_collection/uk_bin_collection/councils/ReadingBoroughCouncil.py,sha256=ZlQjU0IeKylGE9VlivSMh4XKwoLgntESPiylSOYkuD4,1009
@@ -181,6 +183,7 @@ uk_bin_collection/uk_bin_collection/councils/ThreeRiversDistrictCouncil.py,sha25
181
183
  uk_bin_collection/uk_bin_collection/councils/TonbridgeAndMallingBC.py,sha256=UlgnHDoi8ecav2H5-HqKNDpqW1J3RN-c___5c08_Q7I,4859
182
184
  uk_bin_collection/uk_bin_collection/councils/TorbayCouncil.py,sha256=JW_BS7wkfxFsmx6taQtPAQWdBp1AfLrxs0XRQ2XZcSw,2029
183
185
  uk_bin_collection/uk_bin_collection/councils/TorridgeDistrictCouncil.py,sha256=6gOO02pYU0cbj3LAHiBVNG4zkFMyIGbkE2jAye3KcGM,6386
186
+ uk_bin_collection/uk_bin_collection/councils/TunbridgeWellsCouncil.py,sha256=s8Nm9Ef-4561mEXPa0ylYHrXyYIulgCcNV2uAnrXyZk,2846
184
187
  uk_bin_collection/uk_bin_collection/councils/UttlesfordDistrictCouncil.py,sha256=GSELWbSn5jtznv6FSLIMxK6CyQ27MW9FoY_m5jhTEBA,4175
185
188
  uk_bin_collection/uk_bin_collection/councils/ValeofGlamorganCouncil.py,sha256=Phgb_ECiUOOkqOx6OsfsTHMCW5VQfRmOC2zgYIQhuZA,5044
186
189
  uk_bin_collection/uk_bin_collection/councils/ValeofWhiteHorseCouncil.py,sha256=KBKGHcWAdPC_8-CfKnLOdP7Ww6RIvlxLIJGqBsq_77g,4208
@@ -210,8 +213,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
210
213
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
211
214
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
212
215
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
213
- uk_bin_collection-0.98.5.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
214
- uk_bin_collection-0.98.5.dist-info/METADATA,sha256=hbuONB_eNHQmV4S23Zggy6yYeSXl5wI-YQrWkYlld58,16843
215
- uk_bin_collection-0.98.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
216
- uk_bin_collection-0.98.5.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
217
- uk_bin_collection-0.98.5.dist-info/RECORD,,
216
+ uk_bin_collection-0.99.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
217
+ uk_bin_collection-0.99.0.dist-info/METADATA,sha256=aakearxZxxoL0MqAE2WaAqz1NPpl2ePxoPHxxdkQHpU,16843
218
+ uk_bin_collection-0.99.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
219
+ uk_bin_collection-0.99.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
220
+ uk_bin_collection-0.99.0.dist-info/RECORD,,