From 5fa80077aa8184e29f137fe26ed8627f4c71912c Mon Sep 17 00:00:00 2001 From: Justus Kuhlmann Date: Tue, 8 Apr 2025 14:47:55 +0000 Subject: [PATCH] enable import of multiple toml files at once via cli --- corrlib/cli.py | 7 ++++--- corrlib/toml.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/corrlib/cli.py b/corrlib/cli.py index 3f72bd6..ff4f374 100644 --- a/corrlib/cli.py +++ b/corrlib/cli.py @@ -2,7 +2,7 @@ from typing import Optional import typer from corrlib import __app_name__, __version__ from .initialization import create -from .toml import import_toml, update_project +from .toml import import_tomls, update_project from .find import find_record, find_project, list_projects from .tools import str2list import os @@ -82,7 +82,7 @@ def importer( "--dataset", "-d", ), - file: str = typer.Argument( + files: str = typer.Argument( ), copy_file: bool = typer.Option( bool(True), @@ -93,7 +93,8 @@ def importer( """ Import a project from a .toml-file via CLI. """ - import_toml(path, file, copy_file) + file_list = files.split(",") + import_tomls(path, file_list, copy_file) return diff --git a/corrlib/toml.py b/corrlib/toml.py index 45dcb1f..9735bad 100644 --- a/corrlib/toml.py +++ b/corrlib/toml.py @@ -45,6 +45,11 @@ def check_measurement_data(measurements: dict, code: str) -> None: return +def import_tomls(path: str, files: str, copy_files: bool=True) -> None: + for file in files: + import_toml(path, file, copy_files) + + def import_toml(path: str, file: str, copy_file: bool=True) -> None: """ Import a project decribed by a .toml file.