
from data_collection.management.commands import BaseShpImporter, import_polling_station_shapefiles

class Command(BaseShpImporter):
    """
    Imports the Polling Station data from Wokingham Council
    """
    council_id     = 'E06000037'
    districts_name = 'polling_districts'
    stations_name  = 'polling_places.shp'
 
   def district_record_to_dict(self, record): 
        return {
            'internal_council_id': record[0],
            'name': record[2],
        }


    def station_record_to_dict(self, record):
        return {
            'internal_council_id': record[4],
            'postcode'           : record[5].split(',')[-1],
            'address'            : "\n".join(record[5].split(',')[:-1]),
        }
    
    def import_polling_stations(self):
        import_polling_station_shapefiles(self)


from data_collection.management.commands import BaseShpShpImporter

class Command(BaseShpShpImporter):
    """
    Imports the Polling Station data from Wokingham Council
    """
    council_id     = 'E06000037'
    districts_name = 'polling_districts'
    stations_name  = 'polling_places.shp'
    
    def district_record_to_dict(self, record): 
        return {
            'internal_council_id': record[0],
            'name': record[2],
        }

    def station_record_to_dict(self, record):
        return {
            'internal_council_id': record[4],
            'postcode'           : record[5].split(',')[-1],
            'address'            : "\n".join(record[5].split(',')[:-1]),
        }

Refactor West Berks to use new BaseShpShpImporter
Refactor West Berks to use new BaseShpShpImporter

  
- from data_collection.management.commands import BaseShpImporter, import_polling_station_shapefiles
+ from data_collection.management.commands import BaseShpShpImporter
  
- class Command(BaseShpImporter):
+ class Command(BaseShpShpImporter):
      """
      Imports the Polling Station data from Wokingham Council
      """
      council_id     = 'E06000037'
      districts_name = 'polling_districts'
      stations_name  = 'polling_places.shp'
-  
+     
-    def district_record_to_dict(self, record): 
+     def district_record_to_dict(self, record): 
          return {
              'internal_council_id': record[0],
              'name': record[2],
          }
- 
  
      def station_record_to_dict(self, record):
          return {
              'internal_council_id': record[4],
              'postcode'           : record[5].split(',')[-1],
              'address'            : "\n".join(record[5].split(',')[:-1]),
          }
-     
-     def import_polling_stations(self):
-         import_polling_station_shapefiles(self)
  
Refactor West Berks to use new BaseShpShpImporter
## Code Before:

from data_collection.management.commands import BaseShpImporter, import_polling_station_shapefiles

class Command(BaseShpImporter):
    """
    Imports the Polling Station data from Wokingham Council
    """
    council_id     = 'E06000037'
    districts_name = 'polling_districts'
    stations_name  = 'polling_places.shp'
 
   def district_record_to_dict(self, record): 
        return {
            'internal_council_id': record[0],
            'name': record[2],
        }


    def station_record_to_dict(self, record):
        return {
            'internal_council_id': record[4],
            'postcode'           : record[5].split(',')[-1],
            'address'            : "\n".join(record[5].split(',')[:-1]),
        }
    
    def import_polling_stations(self):
        import_polling_station_shapefiles(self)

## Instruction:
Refactor West Berks to use new BaseShpShpImporter
## Code After:

from data_collection.management.commands import BaseShpShpImporter

class Command(BaseShpShpImporter):
    """
    Imports the Polling Station data from Wokingham Council
    """
    council_id     = 'E06000037'
    districts_name = 'polling_districts'
    stations_name  = 'polling_places.shp'
    
    def district_record_to_dict(self, record): 
        return {
            'internal_council_id': record[0],
            'name': record[2],
        }

    def station_record_to_dict(self, record):
        return {
            'internal_council_id': record[4],
            'postcode'           : record[5].split(',')[-1],
            'address'            : "\n".join(record[5].split(',')[:-1]),
        }
