Ejemplo n.º 1
0
 def get_name_map(self, filepath):
     s3 = S3Wrapper(settings.LGBCE_BUCKET)
     basepath = os.path.split(filepath)[0]
     try:
         # we specify corrections to names in the LGBCE shapefiles
         # by adding a name_map.json file to the same S3 directory
         # where the shape files are saved
         f = s3.get_file(basepath + '/name_map.json')
         return json.load(open(f.name))
     except ClientError as e:
         if int(e.response['Error']['Code']) == 404:
             # if we didn't find any name map file, return an empty map
             # i.e: just assume the names in the file are correct
             return {}
         else:
             # re-throw any other error
             raise
Ejemplo n.º 2
0
 def read_from_s3(self, filepath):
     s3 = S3Wrapper(self.S3_BUCKET_NAME)
     return s3.get_file(filepath)
Ejemplo n.º 3
0
 def get_data(self, filepath):
     s3 = S3Wrapper(settings.LGBCE_BUCKET)
     f = s3.get_file(filepath)
     tempdir = unzip(f.name)
     ds = DataSource(tempdir)
     return (tempdir, ds)