def address_record_to_dict(self, record): address = format_residential_address([ record.add1.strip(), record.add2.strip(), record.add3.strip(), record.add4.strip(), record.add5.strip(), record.add6.strip(), record.add7.strip(), record.add8.strip(), record.add9.strip(), ]).strip() postcode = Postcode(record.postcode.strip(), ).without_space uprn = record.uprn.lstrip("0").strip() if uprn == "10012752190": postcode = "GL2 8AA" rec = { "address": address, "postcode": postcode, "polling_station_id": record.polling_district.strip(), "uprn": uprn, } return rec
def get_residential_address(self, record): def replace_na(text): if text.strip() == "n/a": return "" return text.strip() address_line_1 = replace_na(record.housename) if replace_na(record.substreetname): address_line_2 = (replace_na(record.housenumber) + " " + replace_na(record.substreetname)).strip() address_line_3 = (replace_na(record.streetnumber) + " " + replace_na(record.streetname)).strip() else: address_line_2 = (replace_na(record.housenumber) + " " + replace_na(record.streetname)).strip() address_line_3 = "" address = format_residential_address([ address_line_1.strip(), address_line_2.strip(), address_line_3.strip(), replace_na(record.locality), replace_na(record.town), replace_na(record.adminarea), ]) return address.strip()
def address_record_to_dict(self, record): if record.post_code.strip() == "": return None address = format_residential_address( [ record.addressline1, record.addressline2, record.addressline3, record.addressline4, ] ) uprn = getattr(record, self.residential_uprn_field).strip().lstrip("0") postcode = record.post_code.strip() ret = { "address": address.strip(), "postcode": postcode, "polling_station_id": getattr(record, self.station_id_field).strip(), "uprn": uprn, } # corrections if postcode in ["TS25 2HE", "TS24 0HJ"]: return None if uprn in ["10090068484", "10009734034", "100110786034"]: ret["accept_suggestion"] = True if uprn in ["100110673453", "100110673049"]: ret["accept_suggestion"] = False return ret
def address_record_to_dict(self, record): address = format_residential_address( [ record.qualadd1.strip(), record.qualadd2.strip(), record.qualadd3.strip(), record.qualadd4.strip(), record.qualadd5.strip(), record.qualadd6.strip(), ] ).strip() postcode = Postcode(record.qualpcode.strip()).without_space uprn = record.qualuprn.lstrip("0").strip() rec = { "address": address, "postcode": postcode, "polling_station_id": record.district.strip(), "uprn": uprn, } if uprn == "100090794910": rec["postcode"] = "NR7 8XA" if uprn == "100090819705": rec["postcode"] = "NR7 9NQ" if uprn == "100090830032": rec["postcode"] = "NR7 9HA" if uprn in [ "200004286426", # NR134LQ -> NR134LH : SUNNY ACRES, YARMOUTH ROAD, BLOFIELD, NORWICH "100091546289", # NR134BL -> NR134NH : DAVSCOTT HOUSE, 1 BUCKENHAM LANE, LINGWOOD, NORWICH "100090801722", # NR70TW -> NR78UB : 35 CLOVER COURT, SPROWSTON, NORWICH ]: rec["accept_suggestion"] = True if uprn in [ "10009922833", "100090814819", # NR65NG -> NR65NS : AMBERLEA, 67 MIDDLETONS LANE, HELLESDON, NORWICH "10009923828", # NR205PT -> NR205PS : 4 KERDISTON ROAD, THEMELTHORPE, DEREHAM "200004287047", # NR205PT -> NR205PS : 5 KERDISTON ROAD, THEMELTHORPE, DEREHAM ]: rec["accept_suggestion"] = False return rec
def address_record_to_dict(self, record): address = format_residential_address([ record.col2.strip(), record.col3.strip(), record.col4.strip(), record.col5.strip(), ]).strip() postcode = Postcode(record.col6.strip()).without_space rec = { "address": address, "postcode": postcode, "polling_station_id": record.col1.strip(), "uprn": "", } return rec
def address_record_to_dict(self, record): if record.col22.strip() == "47237285": return None address = format_residential_address([ record.col13.strip(), record.col14.strip(), record.col15.strip(), record.col16.strip(), record.col17.strip(), ]) return { "address": address.strip(), "postcode": record.col21.strip(), "polling_station_id": record.col12.strip(), "uprn": record.col22.strip(), }
def address_record_to_dict(self, record): address = format_residential_address([ record.elector_address1.strip(), record.elector_address2.strip(), record.elector_address3.strip(), record.elector_address4.strip(), record.elector_address5.strip(), record.elector_address6.strip(), record.elector_address7.strip(), record.elector_address8.strip(), ]) return { "address": address.strip(), "postcode": Postcode(record.elector_address9.strip()).without_space, "polling_station_id": record.polling_district.strip(), }
def address_record_to_dict(self, record): uprn = record.col36.strip() postcode = record.col35.strip() if uprn == "47237285": return None if postcode in ["NE25 9BE", "NE27 0PJ"]: return None address = format_residential_address([ record.col27.strip(), record.col28.strip(), record.col29.strip(), record.col30.strip(), record.col31.strip(), record.col32.strip(), ]) rec = { "address": address.strip(), "postcode": postcode, "polling_station_id": record.col12.strip(), "uprn": uprn, } if address == "30 PHOENIX RISE, MOOR PARK NORTH SHIELDS": return None if uprn in [ "47029975", # NE237JT -> NE237JU : EAST BARNS, GREENS HOUSES FARM, DUDLEY LANE, SEATON BURN "47035320", # NE237AG -> NE237AF : RESIDENTIAL HOUSE AT, 83 FERN DRIVE, DUDLEY "47093421", # NE299JU -> NE296SL : THE OLD VICARAGE, PRESTON ROAD, NORTH SHIELDS "47102033", # NE304HQ -> NE304NU : FLAT 3, 45 PERCY GARDENS, TYNEMOUTH "47102032", # NE304HQ -> NE304NU : FLAT 2, 45 PERCY GARDENS, TYNEMOUTH "47072823", # NE258RU -> NE270XL : 19 PRIORY AVENUE, WHITLEY BAY "47072822", # NE258RU -> NE270XL : 18 PRIORY AVENUE, WHITLEY BAY "47072818", # NE258RU -> NE270XL : 14 PRIORY AVENUE, WHITLEY BAY ]: rec["accept_suggestion"] = False return rec
def address_record_to_dict(self, record): if record.addressline6.strip() == "": return None address = format_residential_address([ record.addressline1, record.addressline2, record.addressline3, record.addressline4, record.addressline5, ]) uprn = getattr(record, self.residential_uprn_field).strip() return { "address": address.strip(), "postcode": record.addressline6.strip(), "polling_station_id": getattr(record, self.station_id_field).strip(), "uprn": uprn, }
def address_record_to_dict(self, record): postcode = record.pcode.strip() if postcode == "AL69DJ": return None address = format_residential_address([ record.electoradd1.strip(), record.electoradd2.strip(), record.electoradd3.strip(), record.electoradd4.strip(), record.electoradd5.strip(), record.electoradd6.strip(), ]) rec = { "address": address.strip(), "postcode": record.pcode.strip(), "polling_station_id": record.code.strip(), "uprn": "", } return rec
def get_residential_address(self, record): def replace_na(text): if text.strip() == "n/a": return "" return text.strip() address_line_1 = (replace_na(record.housename) + " " + replace_na(record.housenumber)) address_line_1 = address_line_1.strip() street_address = (replace_na(record.streetnumber) + " " + replace_na(record.streetname)) street_address = street_address.strip() address_line_1 = address_line_1 + " " + street_address address = format_residential_address([ address_line_1.strip(), replace_na(record.locality), replace_na(record.town), replace_na(record.adminarea), ]) return address.strip()
def address_record_to_dict(self, record): if getattr(record, self.postcode_field).strip() == "A1 1AA": # this is a dummy record return None if not getattr(record, self.postcode_field).strip(): return None address = format_residential_address( [getattr(record, field) for field in self.address_fields]) if "Dummy Record" in address: return None uprn = getattr(record, self.residential_uprn_field).strip() return { "address": address, "postcode": getattr(record, self.postcode_field).strip(), "polling_station_id": getattr(record, self.station_id_field).strip(), "uprn": uprn, }