summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/update_specific_importers.py
blob: 9a13e3f3e5ef81657cc5765bde5992345e4e53ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from optparse import make_option

from django.core.management.base import BaseCommand

IMPORTERS = []

from archaeological_files.data_importer import FileImporterSraPdL
IMPORTERS.append(FileImporterSraPdL)


class Command(BaseCommand):
    help = "Update each specific importer"
    option_list = list(BaseCommand.option_list) + [
        make_option(
            '--force',
            action='store_true',
            dest='force',
            default=False,
            help='Force the deletion of existing importers. '
                 'ATTENTION: all associated imports and all associated items '
                 'will be deleted.')]

    def handle(self, *args, **options):
        for importer in IMPORTERS:
            response = importer()._create_models(force=options['force'])
            if response:
                self.stdout.write("%s configured\n" % importer.__name__)
                self.stdout.flush()