enable import of multiple toml files at once via cli
This commit is contained in:
parent
005c1dd776
commit
5fa80077aa
2 changed files with 9 additions and 3 deletions
|
@ -2,7 +2,7 @@ from typing import Optional
|
||||||
import typer
|
import typer
|
||||||
from corrlib import __app_name__, __version__
|
from corrlib import __app_name__, __version__
|
||||||
from .initialization import create
|
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 .find import find_record, find_project, list_projects
|
||||||
from .tools import str2list
|
from .tools import str2list
|
||||||
import os
|
import os
|
||||||
|
@ -82,7 +82,7 @@ def importer(
|
||||||
"--dataset",
|
"--dataset",
|
||||||
"-d",
|
"-d",
|
||||||
),
|
),
|
||||||
file: str = typer.Argument(
|
files: str = typer.Argument(
|
||||||
),
|
),
|
||||||
copy_file: bool = typer.Option(
|
copy_file: bool = typer.Option(
|
||||||
bool(True),
|
bool(True),
|
||||||
|
@ -93,7 +93,8 @@ def importer(
|
||||||
"""
|
"""
|
||||||
Import a project from a .toml-file via CLI.
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,11 @@ def check_measurement_data(measurements: dict, code: str) -> None:
|
||||||
return
|
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:
|
def import_toml(path: str, file: str, copy_file: bool=True) -> None:
|
||||||
"""
|
"""
|
||||||
Import a project decribed by a .toml file.
|
Import a project decribed by a .toml file.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue