Exemple #1
0
  --help, prints this message.

  --verbosity=<level>, adjusts the level of verbosity of the
  tool. This is a number between 0(quiet) and 3(extremely
  verbose). This is manly for debugging purposes.

  --format=<format>, determines the output format for the dataset.
  Currently the tool supports only DSPL (Dataset publishing Language).

arguments:

  filename, the filename to write the output to.
""" % {
    'regions': "\n  ".join ([regions_dict.get_name(r[0])
                             for r in regions_dict.all()]),

    'pollutants': "\n  ".join ([ "%(formula)s (%(name)s)" % {
            'formula': pollutants_dict.get_formula(p[0]),
            'name': pollutants_dict.get_name(p[0]),
            } for p in pollutants_dict.all() ]),
}


class OptionsManager(object):
    """Provides options management.
    """

    long_options = [
        "help",
        "keep",
Exemple #2
0
OUT_DIR = "out/"

try:
    opts_mgr(sys.argv[1:])

except Exception, e:
    print (e)
    sys.exit(-1)

# hackish :-/
if not opts_mgr.pollutants:
    opts_mgr.pollutants = [
        p[0] for p in pollutants_dict.all()]
if not opts_mgr.regions:
    opts_mgr.regions = [
        r[0] for r in regions_dict.all()]


# main body
if __name__ == "__main__":

    data_mgr = DataManager()

    # Phase 1. Fetch data
    total_rows = 0
    for pollutant_code in opts_mgr.pollutants:
        pollutant_formula = pollutants_dict.get_formula(pollutant_code)
        pollutant_name = pollutants_dict.get_name(pollutant_code)

        for region_code in opts_mgr.regions:
            region_name = regions_dict.get_name(region_code)