diff options
Diffstat (limited to 'archaeological_operations/management/commands')
-rw-r--r-- | archaeological_operations/management/commands/ishtar_imports.py (renamed from archaeological_operations/management/commands/import_operations.py) | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/archaeological_operations/management/commands/import_operations.py b/archaeological_operations/management/commands/ishtar_imports.py index 09bfe23b6..3f4d9e2e8 100644 --- a/archaeological_operations/management/commands/import_operations.py +++ b/archaeological_operations/management/commands/ishtar_imports.py @@ -18,6 +18,7 @@ # See the file COPYING for details. import datetime, unicodecsv +from optparse import make_option from django.conf import settings from django.core.management.base import BaseCommand, CommandError @@ -31,6 +32,12 @@ IMPORTERS = { } try: + from archaeological_files.data_importer import * + IMPORTERS['sra-pdl-files'] = FileImporterSraPdL +except ImportError: + pass + +try: from archaeological_context_records.data_importer import * IMPORTERS['bibracte-ue'] = ContextRecordsImporterBibracte IMPORTERS['bibracte-ue-rel'] = ContextRecordsRelationImporterBibracte @@ -48,6 +55,14 @@ except ImportError: class Command(BaseCommand): args = '<filename> <importer_name> [<nb lines skipped>]' help = "Import archaeological operations" + option_list = BaseCommand.option_list + ( + make_option('--choose-default', + action='store_true', + dest='choose_default', + default=False, + help='When a choice is requested choose the first one available. '\ + 'For testing purpose'), + ) def handle(self, *args, **options): if not args or not args[0]: @@ -62,6 +77,7 @@ class Command(BaseCommand): skip_lines = int(args[2]) except: skip_lines = 0 + choose_default = options.get('choose_default') filename = args[0] importer = IMPORTERS[args[1]](skip_lines=skip_lines, output='cli') sys.stdout.write("*" * 72 + "\n") @@ -76,7 +92,8 @@ class Command(BaseCommand): for encoding in encodings: try: importer.importation([line for line in - unicodecsv.reader(csv_file, encoding='utf-8')]) + unicodecsv.reader(csv_file, encoding='utf-8')], + choose_default=choose_default) errors = importer.get_csv_errors() sys.stdout.write("\n") if errors: |