# Path: geotweet/twitter/load.py
# class S3Loader(object):
#     
#     envvars = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_DEFAULT_REGION']
# 
#     def __init__(self, bucket=None, region=None):
#         self.bucket = bucket
#         if region:
#             os.environ['AWS_DEFAULT_REGION'] = region
#     
#     def valid(self):
#         if not self.bucket:
#             error = "Error: AWS Bucket not set"
#             raise ValueError(error)
#         for envvar in self.envvars:
#             if not os.getenv(envvar):
#                 error = "Error: Environment variable {0} not set".format(envvar)
#                 raise EnvironmentError(error)
# 
#     def store(self, filepath):
#         if not self.bucket:
#             return False
#         filename = filepath.rsplit('/', 1)[-1]
#         s3 = boto3.resource('s3')
#         s3.Object(self.bucket, filename).put(Body=open(filepath, 'rb'))


import os
import sys
import json
import logging
import requests
from os.path import dirname
from imposm.parser import OSMParser
from .twitter.load import S3Loader




SCRIPTDIR = dirname(os.path.abspath(__file__))
DEFAULT_STATES = os.path.join(SCRIPTDIR, 'data/states.txt')
US_GEOFABRIK = 'http://download.geofabrik.de/north-america/us/{0}-latest.osm.pbf'
POI_TAGS = ["amenity", "builing", "shop", "office", "tourism"]


class OSMRunner(object):
    """
    Downloads OSM extracts from GeoFabrik in pbf format

    """
    def __init__(self, args):
        self.states = args.states
        if not args.states:
            self.states = DEFAULT_STATES
        self.output = args.output
        self.overwrite = False

# Path: geotweet/twitter/load.py
# class S3Loader(object):
#     
#     envvars = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_DEFAULT_REGION']
# 
#     def __init__(self, bucket=None, region=None):
#         self.bucket = bucket
#         if region:
#             os.environ['AWS_DEFAULT_REGION'] = region
#     
#     def valid(self):
#         if not self.bucket:
#             error = "Error: AWS Bucket not set"
#             raise ValueError(error)
#         for envvar in self.envvars:
#             if not os.getenv(envvar):
#                 error = "Error: Environment variable {0} not set".format(envvar)
#                 raise EnvironmentError(error)
# 
#     def store(self, filepath):
#         if not self.bucket:
#             return False
#         filename = filepath.rsplit('/', 1)[-1]
#         s3 = boto3.resource('s3')
#         s3.Object(self.bucket, filename).put(Body=open(filepath, 'rb'))


# Path: geotweet/osm.py
import os
import sys
import json
import logging
import requests
from os.path import dirname
from imposm.parser import OSMParser
from .twitter.load import S3Loader





SCRIPTDIR = dirname(os.path.abspath(__file__))
DEFAULT_STATES = os.path.join(SCRIPTDIR, 'data/states.txt')
US_GEOFABRIK = 'http://download.geofabrik.de/north-america/us/{0}-latest.osm.pbf'
POI_TAGS = ["amenity", "builing", "shop", "office", "tourism"]


class OSMRunner(object):
    """
    Downloads OSM extracts from GeoFabrik in pbf format

    """
    def __init__(self, args):
        self.states = args.states
        if not args.states:
            self.states = DEFAULT_STATES
        self.output = args.output
        self.overwrite = False

        self.s3 = S3Loader(bucket=args.bucket, region=args.region)