# Path: tasks/au/data.py
# class XCPAllGeographiesAllTables(WrapperTask):
#     year = IntParameter()
# 
#     def requires(self):
#         for resolution in GEOGRAPHIES[self.year]:
#             yield XCPAllTables(resolution=resolution, year=self.year)
# 
# Path: tasks/meta.py
# def current_session():
#     '''
#     Returns the session relevant to the currently operating :class:`Task`, if
#     any.  Outside the context of a :class:`Task`, this can still be used for
#     manual session management.
#     '''
#     return _current_session.get()
# 
# Path: lib/logger.py
# def get_logger(name):
#     '''
#     Obtain a logger outputing to stderr with specified name. Defaults to INFO
#     log level.
#     '''
#     logger = logging.getLogger(name)
#     if LUIGI_LOG_ARG in sys.argv:
#         index = sys.argv.index(LUIGI_LOG_ARG) + 1
#         if len(sys.argv) > index:
#             logger.setLevel(sys.argv[index])
# 
#     return logger


import os
import json
import csv
from luigi import Task, WrapperTask, Parameter
from luigi.local_target import LocalTarget
from tasks.au.data import XCPAllGeographiesAllTables
from tasks.meta import current_session
from lib.logger import get_logger
    'GEO_POA': 'au.geo.POA',  # Postal Areas
}


class Measurements2CSV(Task):
    geography = Parameter()
    file_name = Parameter()

    def __init__(self, *args, **kwargs):
        super(Measurements2CSV, self).__init__(*args, **kwargs)

    def requires(self):
        return {
            'bcp': XCPAllGeographiesAllTables(year=2011)
        }

    def _get_config_data(self):
        dir_path = os.path.dirname(os.path.realpath(__file__))
        with (open('{}/{}'.format(dir_path, 'measurements.json'))) as f:
            return json.load(f)

    def run(self):
        session = current_session()
        measurements = self._get_config_data()
        for measure in measurements:
            measure['geom_id'] = GEOGRAPHY_LEVELS[self.geography]
        json_metadata = json.dumps(measurements)
        result = session.execute(self._get_meta_query(json_metadata))
        if result:
            join_data = {}

# Path: tasks/au/data.py
# class XCPAllGeographiesAllTables(WrapperTask):
#     year = IntParameter()
# 
#     def requires(self):
#         for resolution in GEOGRAPHIES[self.year]:
#             yield XCPAllTables(resolution=resolution, year=self.year)
# 
# Path: tasks/meta.py
# def current_session():
#     '''
#     Returns the session relevant to the currently operating :class:`Task`, if
#     any.  Outside the context of a :class:`Task`, this can still be used for
#     manual session management.
#     '''
#     return _current_session.get()
# 
# Path: lib/logger.py
# def get_logger(name):
#     '''
#     Obtain a logger outputing to stderr with specified name. Defaults to INFO
#     log level.
#     '''
#     logger = logging.getLogger(name)
#     if LUIGI_LOG_ARG in sys.argv:
#         index = sys.argv.index(LUIGI_LOG_ARG) + 1
#         if len(sys.argv) > index:
#             logger.setLevel(sys.argv[index])
# 
#     return logger


# Path: tasks/geographica/au/csv.py
import os
import json
import csv
from luigi import Task, WrapperTask, Parameter
from luigi.local_target import LocalTarget
from tasks.au.data import XCPAllGeographiesAllTables
from tasks.meta import current_session
from lib.logger import get_logger

    'GEO_POA': 'au.geo.POA',  # Postal Areas
}


class Measurements2CSV(Task):
    geography = Parameter()
    file_name = Parameter()

    def __init__(self, *args, **kwargs):
        super(Measurements2CSV, self).__init__(*args, **kwargs)

    def requires(self):
        return {
            'bcp': XCPAllGeographiesAllTables(year=2011)
        }

    def _get_config_data(self):
        dir_path = os.path.dirname(os.path.realpath(__file__))
        with (open('{}/{}'.format(dir_path, 'measurements.json'))) as f:
            return json.load(f)

    def run(self):
        session = current_session()
        measurements = self._get_config_data()
        for measure in measurements:
            measure['geom_id'] = GEOGRAPHY_LEVELS[self.geography]
        json_metadata = json.dumps(measurements)
        result = session.execute(self._get_meta_query(json_metadata))
        if result:
            join_data = {}

            join_data['numer'] = {}