Beispiel #1
0
    def setUp(self):
        self.user = User()
        self.user.save()
        token = Token.objects.create(user=self.user)
        token.save()
        self.valid_token = 'Token ' + str(self.user.auth_token)

        AddressBaseBasicImporter().import_csv(
            self._sample_data_file('addressbase_basic_barnet_sample.csv'))
        PostcodeGssCodeImporter().import_postcode_gss_codes(
            self._sample_data_file('NSPL_barnet_sample.csv'))
        LocalAuthoritiesImporter().import_local_authorities(
            self._sample_data_file('local_authorities_sample.nt'))
def rerun_nspl_import(apps, schema_editor):
    if settings.DEBUG or settings.TESTING:
        print 'not in production - skipping re-import of NSPL'
    else:
        destination_dir = dest_dir('/tmp/postcode_gss_codes/')
        filepath = PostcodeGssCodeDownloader().download(destination_dir)
        if isinstance(filepath, list):
            filepath = filepath[0]

        files = ZipExtractor(filepath).unzip_if_needed('.*NSPL.*\.csv')
        for path in files:
            print 'importing ' + path
            PostcodeGssCodeImporter().import_postcode_gss_codes(path)
 def _import(self, downloaded_file):
     importer = PostcodeGssCodeImporter()
     importer.import_postcode_gss_codes(downloaded_file)
Beispiel #4
0
 def _importer(self):
     return PostcodeGssCodeImporter()
Beispiel #5
0
def import_csv(filename):
    if not os.access(filename, os.R_OK):
        raise CommandError('CSV file could not be read')

    importer = PostcodeGssCodeImporter()
    importer.import_postcode_gss_codes(filename)