uk_bin_collection 0.77.0__py3-none-any.whl → 0.78.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.
@@ -241,6 +241,11 @@ Feature: Test each council output matches expected results
241
241
  | council |
242
242
  | ErewashBoroughCouncil |
243
243
 
244
+ @FarehamBoroughCouncil
245
+ Examples: FarehamBoroughCouncil
246
+ | council |
247
+ | FarehamBoroughCouncil |
248
+
244
249
  @FenlandDistrictCouncil
245
250
  Examples: FenlandDistrictCouncil
246
251
  | council |
@@ -342,6 +342,12 @@
342
342
  "url": "https://map.erewash.gov.uk/isharelive.web/myerewash.aspx",
343
343
  "wiki_name": "Erewash Borough Council"
344
344
  },
345
+ "FarehamBoroughCouncil": {
346
+ "postcode": "PO14 4NR",
347
+ "skip_get_url": true,
348
+ "url": "https://www.fareham.gov.uk/internetlookups/search_data.aspx?type=JSON&list=DomesticBinCollections&Road=&Postcode=PO14%204NR",
349
+ "wiki_name": "Fareham Borough Council"
350
+ },
345
351
  "FenlandDistrictCouncil": {
346
352
  "skip_get_url": true,
347
353
  "uprn": "200002981143",
@@ -0,0 +1,69 @@
1
+ import json
2
+
3
+ import requests
4
+ from uk_bin_collection.uk_bin_collection.common import *
5
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
6
+
7
+ class CouncilClass(AbstractGetBinDataClass):
8
+ """
9
+ Concrete classes have to implement all abstract operations of the
10
+ base class. They can also override some operations with a default
11
+ implementation.
12
+ """
13
+
14
+ def parse_data(self, page: str, **kwargs) -> dict:
15
+ user_postcode = kwargs.get("postcode")
16
+ check_postcode(user_postcode)
17
+
18
+ headers = {
19
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
20
+ }
21
+ params = {
22
+ "type": "JSON",
23
+ "list": "DomesticBinCollections",
24
+ "Road": "",
25
+ "Postcode": user_postcode
26
+ }
27
+
28
+ response = requests.get(
29
+ "https://www.fareham.gov.uk/internetlookups/search_data.aspx",
30
+ params = params,
31
+ headers = headers
32
+ )
33
+
34
+ bin_data = response.json()["data"]
35
+ data = {"bins": []}
36
+
37
+ if "rows" in bin_data:
38
+ collection_str = bin_data["rows"][0]["DomesticBinDay"]
39
+
40
+ results = re.findall(r"(\d\d?\/\d\d?\/\d{4}) \((\w*)\)", collection_str)
41
+
42
+ if results:
43
+ for result in results:
44
+ collection_date = datetime.strptime(result[0], "%d/%m/%Y")
45
+ dict_data = {
46
+ "type": result[1],
47
+ "collectionDate": collection_date.strftime(date_format),
48
+ }
49
+ data["bins"].append(dict_data)
50
+
51
+ # Garden waste is also collected on recycling day
52
+ if (dict_data["type"] == "Recycling"):
53
+ garden_data = {
54
+ "type": "Garden",
55
+ "collectionDate": dict_data["collectionDate"],
56
+ }
57
+ data["bins"].append(garden_data)
58
+ else:
59
+ raise RuntimeError("Dates not parsed correctly.")
60
+ else:
61
+ raise ValueError("Postcode not found on website.")
62
+
63
+ data["bins"].sort(
64
+ key=lambda x: datetime.strptime(
65
+ x.get("collectionDate"), "%d/%m/%Y"
66
+ )
67
+ )
68
+
69
+ return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.77.0
3
+ Version: 0.78.0
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -1,8 +1,8 @@
1
1
  uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  uk_bin_collection/tests/council_feature_input_parity.py,sha256=_BINFpWMsMg91Jf1MYydPykOi8gu06x8C-E2AdT0A3Q,5205
3
3
  uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
4
- uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=JfARfiOGbj6ENoieIpFw0XKmkGgm4krWg8sbofgx9k4,16357
5
- uk_bin_collection/tests/input.json,sha256=PaincPdmWl4MqajMT9-79qGNOK2Zz2cgAY2_bTuy4gk,53745
4
+ uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=KBY8I28P8v-ONJjwQvG23ifiPXCORn-jg-V39nDMI2k,16465
5
+ uk_bin_collection/tests/input.json,sha256=T_vMqcs4bGTlTctCVvy9NiwoAhX1NT42Q0YzybESQxo,54042
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=Pg3Z7c3zrebx1w-yIZ9xTJ3E-okVndlNIAJL-F46HKU,2962
@@ -57,6 +57,7 @@ uk_bin_collection/uk_bin_collection/councils/EastSuffolkCouncil.py,sha256=qQ0oOf
57
57
  uk_bin_collection/uk_bin_collection/councils/EastleighBoroughCouncil.py,sha256=V4Vso4DvawFiezKlmXbTlJEK9Sjhz9nA8WeYjwtO2e4,2310
58
58
  uk_bin_collection/uk_bin_collection/councils/EnvironmentFirst.py,sha256=_9QJYDHpdnYK5R6znvZk1w0F9GnPnI8G4b6I_p26h4U,1695
59
59
  uk_bin_collection/uk_bin_collection/councils/ErewashBoroughCouncil.py,sha256=QTQA6NjZtTL2baDeerIQW1SQpawwu6kGDMGdVvYQRRo,2501
60
+ uk_bin_collection/uk_bin_collection/councils/FarehamBoroughCouncil.py,sha256=61PRsYvwyG_gYNTUqGtjnKJ-fNrjmZf6bqNbxAwurhQ,2450
60
61
  uk_bin_collection/uk_bin_collection/councils/FenlandDistrictCouncil.py,sha256=sFrnKzIE2tIcz0YrC6A9HcevzgNdf6E6_HLGMWDKtGw,2513
61
62
  uk_bin_collection/uk_bin_collection/councils/ForestOfDeanDistrictCouncil.py,sha256=xO5gqgsN9K-cQsuDoQF7ycZkjNdCPAQwIYOCFWxFJ_Y,4504
62
63
  uk_bin_collection/uk_bin_collection/councils/GatesheadCouncil.py,sha256=Ecq4kMbtAHnQrnxjhC7CG3oEZQ3D1aAk5qXVZk-ouxc,4601
@@ -165,8 +166,8 @@ uk_bin_collection/uk_bin_collection/councils/WyreCouncil.py,sha256=zDDa7n4K_zm5P
165
166
  uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bIdsvmoSzBjJAvTTi6yPfJa8xjJx1ys2w,1490
166
167
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
167
168
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=9qppF2oPkhmOoK8-ZkRIU1M6vhBh-yUCWAZEEd07iLk,5414
168
- uk_bin_collection-0.77.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
169
- uk_bin_collection-0.77.0.dist-info/METADATA,sha256=dWmzwfpIqThI-9oJf3jASJodK51-kB5TO1bgM_XJdY0,12594
170
- uk_bin_collection-0.77.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
171
- uk_bin_collection-0.77.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
172
- uk_bin_collection-0.77.0.dist-info/RECORD,,
169
+ uk_bin_collection-0.78.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
170
+ uk_bin_collection-0.78.0.dist-info/METADATA,sha256=v9XlHA0dAhpDBuF1d6qka2eCRqHc7p0I0Fh651hy4yg,12594
171
+ uk_bin_collection-0.78.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
172
+ uk_bin_collection-0.78.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
173
+ uk_bin_collection-0.78.0.dist-info/RECORD,,