bug fix, enable add alias from cli, reimporter implemented in cli
This commit is contained in:
parent
65be802325
commit
4a179bfa12
1 changed files with 48 additions and 4 deletions
|
@ -2,9 +2,10 @@ 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_tomls, update_project
|
from .toml import import_tomls, update_project, reimport_project
|
||||||
from .find import find_record, find_project, list_projects
|
from .find import find_record, list_projects
|
||||||
from .tools import str2list
|
from .tools import str2list
|
||||||
|
from .main import update_aliases
|
||||||
import os
|
import os
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
@ -51,10 +52,32 @@ def list(
|
||||||
elif entities == 'projects':
|
elif entities == 'projects':
|
||||||
results = list_projects(path)
|
results = list_projects(path)
|
||||||
print("Projects:")
|
print("Projects:")
|
||||||
header = "UUID".ljust(37) + "| Names"
|
header = "UUID".ljust(37) + "| Aliases"
|
||||||
print(header)
|
print(header)
|
||||||
for project in results:
|
for project in results:
|
||||||
print(project[0], "|", " | ".join(str2list(project[1])))
|
if project[1] is not None:
|
||||||
|
aliases = " | ".join(str2list(project[1]))
|
||||||
|
else:
|
||||||
|
aliases = "---"
|
||||||
|
print(project[0], "|", aliases)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def alias_add(
|
||||||
|
path: str = typer.Option(
|
||||||
|
str('./corrlib'),
|
||||||
|
"--dataset",
|
||||||
|
"-d",
|
||||||
|
),
|
||||||
|
uuid: str = typer.Argument(),
|
||||||
|
alias: str = typer.Argument(),
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Add an alias to a project UUID.
|
||||||
|
"""
|
||||||
|
alias_list = alias.pülit(",")
|
||||||
|
update_aliases(path, uuid, alias_list)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +121,27 @@ def importer(
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def reimporter(
|
||||||
|
path: str = typer.Option(
|
||||||
|
str('./corrlib'),
|
||||||
|
"--dataset",
|
||||||
|
"-d",
|
||||||
|
),
|
||||||
|
ident: str = typer.Argument()
|
||||||
|
) -> None:
|
||||||
|
uuid = ident.split("::")[0]
|
||||||
|
if len(ident.split("::")) > 1:
|
||||||
|
toml_file = os.path.join(path, "toml_imports", ident.split("::")[1])
|
||||||
|
if os.path.exists(toml_file):
|
||||||
|
import_tomls(path, [toml_file], copy_files=False)
|
||||||
|
else:
|
||||||
|
raise Exception("This file is not known for this project.")
|
||||||
|
else:
|
||||||
|
reimport_project(path, uuid)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def init(
|
def init(
|
||||||
path: str = typer.Option(
|
path: str = typer.Option(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue