diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-03-06 11:15:13 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-05-06 16:06:35 +0200 |
commit | 3cbc3abd69b2b9f60f5e1dda0fec8eb3e6853656 (patch) | |
tree | 9408423a8a8036027df54d4c52d8ee8635fb3d3c /archaeological_operations | |
parent | 906843389ca8e090da79c289affb4ac0574ab47b (diff) | |
download | Ishtar-3cbc3abd69b2b9f60f5e1dda0fec8eb3e6853656.tar.bz2 Ishtar-3cbc3abd69b2b9f60f5e1dda0fec8eb3e6853656.zip |
Data importation: add an option to select the default choice (for testing)
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/management/commands/ishtar_imports.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/archaeological_operations/management/commands/ishtar_imports.py b/archaeological_operations/management/commands/ishtar_imports.py index 23397204b..3f4d9e2e8 100644 --- a/archaeological_operations/management/commands/ishtar_imports.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 @@ -54,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]: @@ -68,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") @@ -82,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: |