# Path: tasks/ca/statcan/data.py
# class AllCensusTopics(BaseParams, WrapperTask):
#     def requires(self):
#         topic_range = list(range(1, 11))   # 1-10
# 
#         for resolution in (GEO_CT, GEO_PR, GEO_CD, GEO_CSD, GEO_CMA, GEO_DA, GEO_FSA):
#             for count in topic_range:
#                 topic = 't{:03d}'.format(count)
#                 yield Census(resolution=resolution, survey=SURVEY_CEN, topic=topic)
# 
# class AllNHSTopics(BaseParams, WrapperTask):
#     def requires(self):
#         topic_range = list(range(1, 30))   # 1-29
# 
#         for resolution in (GEO_CT, GEO_PR, GEO_CD, GEO_CSD, GEO_CMA, GEO_DA, GEO_FSA):
#             for count in topic_range:
#                 topic = 't{:03d}'.format(count)
#                 yield NHS(resolution=resolution, survey=SURVEY_NHS, topic=topic)
# 
# 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.ca.statcan.data import AllCensusTopics, AllNHSTopics
from tasks.meta import current_session
from lib.logger import get_logger


LOGGER = get_logger(__name__)

GEOGRAPHY_LEVELS = {
    'GEO_PR': 'ca.statcan.geo.pr_',  # Canada, provinces and territories
    'GEO_CD': 'ca.statcan.geo.cd_',  # Census divisions
    'GEO_DA': 'ca.statcan.geo.da_',  # Census dissemination areas
    'GEO_FSA': 'ca.statcan.geo.fsa',  # Forward Sortation 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/ca/statcan/data.py
# class AllCensusTopics(BaseParams, WrapperTask):
#     def requires(self):
#         topic_range = list(range(1, 11))   # 1-10
# 
#         for resolution in (GEO_CT, GEO_PR, GEO_CD, GEO_CSD, GEO_CMA, GEO_DA, GEO_FSA):
#             for count in topic_range:
#                 topic = 't{:03d}'.format(count)
#                 yield Census(resolution=resolution, survey=SURVEY_CEN, topic=topic)
# 
# class AllNHSTopics(BaseParams, WrapperTask):
#     def requires(self):
#         topic_range = list(range(1, 30))   # 1-29
# 
#         for resolution in (GEO_CT, GEO_PR, GEO_CD, GEO_CSD, GEO_CMA, GEO_DA, GEO_FSA):
#             for count in topic_range:
#                 topic = 't{:03d}'.format(count)
#                 yield NHS(resolution=resolution, survey=SURVEY_NHS, topic=topic)
# 
# 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/ca/csv.py
import os
import json
import csv
from luigi import Task, WrapperTask, Parameter
from luigi.local_target import LocalTarget
from tasks.ca.statcan.data import AllCensusTopics, AllNHSTopics
from tasks.meta import current_session
from lib.logger import get_logger



LOGGER = get_logger(__name__)

GEOGRAPHY_LEVELS = {
    'GEO_PR': 'ca.statcan.geo.pr_',  # Canada, provinces and territories
    'GEO_CD': 'ca.statcan.geo.cd_',  # Census divisions
    'GEO_DA': 'ca.statcan.geo.da_',  # Census dissemination areas
    'GEO_FSA': 'ca.statcan.geo.fsa',  # Forward Sortation Areas
}


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

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

    def requires(self):
        return {

            'nhs': AllNHSTopics(),