# 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


LOGGER = get_logger(__name__)

GEOGRAPHY_LEVELS = {
    'GEO_STE': 'au.geo.STE',  # State/Territory
    'GEO_SA4': 'au.geo.SA4',  # Statistical Area Level 4
    'GEO_SA3': 'au.geo.SA3',  # Statistical Area Level 3
    'GEO_SA2': 'au.geo.SA2',  # Statistical Area Level 2
    'GEO_SA1': 'au.geo.SA1',  # Statistical Area Level 1
    'GEO_MB': 'au.geo.MB',  # Mesh blocks
    '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 {

# 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



LOGGER = get_logger(__name__)

GEOGRAPHY_LEVELS = {
    'GEO_STE': 'au.geo.STE',  # State/Territory
    'GEO_SA4': 'au.geo.SA4',  # Statistical Area Level 4
    'GEO_SA3': 'au.geo.SA3',  # Statistical Area Level 3
    'GEO_SA2': 'au.geo.SA2',  # Statistical Area Level 2
    'GEO_SA1': 'au.geo.SA1',  # Statistical Area Level 1
    'GEO_MB': 'au.geo.MB',  # Mesh blocks
    '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)