Example #1
0
        print "%-15s" % ins_imp
        print "-" * 15

if options.imports:
    backend = None
    DATA_TYPES = ("elections", "parties", "candidates", "prebudgets", 
                  "prebudgets_csv")

    for imp in options.imports:
        if imp not in DATA_TYPES:
            sys.stderr.write("Unsupported data type '%s'.\nSupported data types:\n" % imp)
            for dt in DATA_TYPES:
                sys.stderr.write("  %s\n" % dt)
            exit(1)

    http = HttpFetcher()

    if not options.disable_cache:
        cache_dir = ".cache"
        http.set_cache_dir(cache_dir)
        requests_cache.configure("importers")

    if options.django:
        from importers.backends.django import DjangoBackend

        # We need to start logging after Django initializes
        # because Django can be configured to reset logging.
        logger = init_logging(debug=options.verbose)
        backend = DjangoBackend(logger, replace=options.replace)
    else:
        logger = init_logging(debug=options.verbose)
Example #2
0
    for ins_imp in options.inspects:
        print "%-15s" % ins_imp
        print "-" * 15

if options.imports:
    backend = None
    DATA_TYPES = ("elections", "parties", "candidates")

    for imp in options.imports:
        if imp not in DATA_TYPES:
            sys.stderr.write("Unsupported data type '%s'.\nSupported data types:\n" % imp)
            for dt in DATA_TYPES:
                sys.stderr.write("  %s\n" % dt)

    logger = init_logging(debug=options.verbose)
    http = HttpFetcher()
    http.set_cache_dir(".cache")
    #requests_cache.configure("importers")

    if options.django:
        from importers.backends.django import DjangoBackend

        backend = DjangoBackend(logger, replace=options.replace)
    else:
        backend = Backend(logger, replace=options.replace)

    for imp_class in importer_list:
        imp_obj = imp_class("data", http, logger, backend)
        importer_objs.append(imp_obj)

    for dt in DATA_TYPES: