From 50b292b48905ec91eeffcd323fd241830dd74983 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Sun, 26 Jul 2020 17:36:52 +0200 Subject: [PATCH] obi import: added --space-priority option to import a view line by line --- python/obitools3/commands/import.pyx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/obitools3/commands/import.pyx b/python/obitools3/commands/import.pyx index 60a7267..bb0a36f 100755 --- a/python/obitools3/commands/import.pyx +++ b/python/obitools3/commands/import.pyx @@ -77,6 +77,11 @@ def addOptions(parser): help="Do a first readthrough of the dataset if it contains huge dictionaries (more than 100 keys) for " "a much faster import. This option is not recommended and will slow down the import in any other case.") + group.add_argument('--space-priority', + action="store_true", dest="import:space_priority", + default=False, + help="If importing a view into another DMS, do it by importing each line, saving disk space if the original view " + "has a line selection associated.") def run(config): @@ -142,7 +147,7 @@ def run(config): else: v = None - if config['obi']['taxdump'] or isinstance(input[1], View): + if config['obi']['taxdump'] or (isinstance(input[1], View) and not config['import']['space_priority']): dms_only=True else: dms_only=False @@ -170,12 +175,15 @@ def run(config): logger("info", "Done.") return - # If importing a view between two DMS, use C API - if isinstance(input[1], View): + # If importing a view between two DMS and not wanting to save space if line selection in original view, use C API + if isinstance(input[1], View) and not config['import']['space_priority']: if obi_import_view(input[0].name_with_full_path, o_dms.name_with_full_path, input[1].name, tobytes((config['obi']['outputURI'].split('/'))[-1])) < 0 : + input[0].close(force=True) + output[0].close(force=True) raise Exception("Error importing a view in a DMS") o_dms.record_command_line(" ".join(sys.argv[1:])) - o_dms.close() + input[0].close(force=True) + output[0].close(force=True) logger("info", "Done.") return