"""
Import Lichfield
"""
from django.contrib.gis.geos import Point

from data_collection.management.commands import (
    BaseShpStationsShpDistrictsImporter
)

class Command(BaseShpStationsShpDistrictsImporter):
    """
    Imports the Polling Station data from Lichfield Council
    """
    council_id     = 'E07000194'
    districts_name = 'Lichfield_District_Council_Polling_Districts'
    stations_name  = 'Lichfield_District_Council_Polling_Station_Locations.shp'
    elections      = ['parl.2015-05-07']

    def district_record_to_dict(self, record):
        return {
            'internal_council_id': record[0],
            'name': record[2],
        }

    def station_record_to_dict(self, record):
        print(record)
        print(record[1])
        print(record[4])
        print(record[5])

        return {
            'internal_council_id': record[0],
            'postcode'           : record[5],
            'address'            : "\n".join([record[1], record[4]]),
        }

@@ -1,72 +1,4 @@
-%22%22%22%0AImport Lichfield%0A%22%22%22%0Afrom django.contrib.gis.geos import Point%0A%0A
 from
@@ -45,14 +45,8 @@
 ort 
-(%0A    
 Base
@@ -81,138 +81,352 @@
 ter%0A
-)%0A%0Aclass Command(BaseShpStationsShpDistrictsImporter):%0A    %22%22%22%0A    Imports the 
+%0A%22%22%22%0ALichfield publish their data on data.gov.uk as zipped shp files%0A%0AI've uploaded the data to Amazon S3 for import purposes%0A%0AAdditionally there's a hashes only scraper at%0Ahttps://morph.io/wdiv-scrapers/DC-
 Polling
- 
 Station
- data from Lichfield Council%0A    %22%22%22
+s-Lichfield%0Apolling the URLs to look for changes.%0A%22%22%22%0A%0Aclass Command(BaseShpStationsShpDistrictsImporter):%0A    srid = 27700
 %0A   
@@ -437,20 +437,16 @@
 ncil_id 
-    
 = 'E0700
@@ -473,34 +473,120 @@
 name = '
-Lichfield_
+local.staffordshire.2017-05-04/Lichfield District Council Polling Districts Shapefile/Lichfield 
 District
 _Council
@@ -577,33 +577,33 @@
 District
-_
+ 
 Council
-_
+ 
 Polling
-_
+ 
 District
@@ -623,20 +623,81 @@
 ns_name 
- 
 = '
+local.staffordshire.2017-05-04/LDC_Polling_Stations_Shapefile/
 Lichfiel
@@ -764,32 +764,42 @@
 ons 
-     = %5B'parl
+= %5B'local.staffordshire
 .201
-5
+7
 -05-0
-7
+4
 '%5D%0A%0A
@@ -893,33 +893,46 @@
 ouncil_id': 
+str(
 record%5B
-0%5D
+3%5D).strip()
 ,%0A          
@@ -945,17 +945,88 @@
 e': 
+str(
 record%5B
-2%5D
+3%5D).strip(),%0A            'polling_station_id': str(record%5B3%5D).strip()
 ,%0A  
@@ -1092,21 +1092,65 @@
     
-print(record)
+address = %22%5Cn%22.join(%5B%0A            str(record%5B1%5D).strip(),
 %0A   
@@ -1154,29 +1154,31 @@
         
-print
+    str
 (record%5B
 1%5D)%0A    
@@ -1173,33 +1173,62 @@
 ord%5B
-1%5D)%0A        print
+4%5D).strip(),%0A        %5D)%0A        postcode = str
 (record%5B
 4%5D)%0A
@@ -1223,19 +1223,27 @@
 (record%5B
-4
+5
 %5D)
+.strip()
 %0A       
@@ -1247,43 +1247,196 @@
     
-print(record%5B5%5D)%0A%0A        return %7B%0A
+codes = %5Brecord%5B9%5D.strip(), record%5B10%5D.strip(), record%5B11%5D.strip()%5D%0A%0A        stations = %5B%5D%0A        for code in codes:%0A            if code != b'':%0A                stations.append(%7B%0A        
     
@@ -1470,19 +1470,27 @@
 d': 
-record%5B0%5D,%0A
+str(code),%0A        
     
@@ -1524,19 +1524,26 @@
   : 
-record%5B5%5D,%0A
+postcode,%0A        
     
@@ -1577,49 +1577,56 @@
   : 
-%22%5Cn%22.join(%5Brecord%5B1%5D, record%5B4%5D%5D),%0A        %7D
+address,%0A                %7D)%0A        return stations
 %0A

update import script for Lichfield