Skip to content

Commit

Permalink
move autosave to main entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 15, 2024
1 parent df28ccd commit d820461
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 47 deletions.
24 changes: 20 additions & 4 deletions src/builder2ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from builder2ibek import __version__
from builder2ibek.builder import Builder
from builder2ibek.convert import dispatch
from builder2ibek.db2autosave import parse_templates

cli = typer.Typer()
yaml = YAML()
Expand All @@ -29,11 +30,11 @@ def main(
help="Print the version of builder2ibek and exit",
),
):
"""Convert build XML to ibek YAML"""
"""Convert xmlbuilder assets to epics-containers assets"""


@cli.command()
def file(
def xml2yaml(
xml: Path = typer.Argument(..., help="Filename of the builder XML file"),
yaml: Optional[Path] = typer.Option(..., help="Output file"),
schema: Optional[str] = typer.Option(
Expand Down Expand Up @@ -77,16 +78,31 @@ def tidy_up(yaml):


@cli.command()
def beamline(
def beamline2yaml(
input: Path = typer.Argument(..., help="Path to root folder BLXX-BUILDER"),
output: Path = typer.Argument(..., help="Output root folder"),
):
"""
Convert a beamline's IOCs from builder to ibek
Convert a beamline's IOCs from builder XML to ibek YAML
"""
typer.echo("Not implemented yet")
raise typer.Exit(code=1)


if __name__ == "__main__":
cli()


@cli.command()
def autosave(
out_folder: Path = typer.Option(
".", help="Output folder to write autosave request files"
),
db_list: list[Path] = typer.Argument(
..., help="List of DB templates with autosave comments"
),
):
"""
Convert DLS autosave DB template comments into autosave req files
"""
parse_templates(out_folder, db_list)
43 changes: 0 additions & 43 deletions src/builder2ibek/db2autosave.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,12 @@
import re
from pathlib import Path

import typer

from builder2ibek import __version__

cli = typer.Typer()


def version_callback(value: bool):
if value:
typer.echo(__version__)
raise typer.Exit()


@cli.callback()
def main(
version: bool | None = typer.Option(
None,
"--version",
callback=version_callback,
is_eager=True,
help="Print the version of builder2ibek and exit",
),
):
"""
Convert DLS autosave DB template comments into autosave req files
"""


regex_autosave = [
re.compile(rf'# *% *autosave *{n} *(.*)[\s\S]*?record *\(.*, *"?([^"]*)"?\)')
for n in range(3)
]


@cli.command()
def db_files(
out_folder: Path = typer.Option(
".", help="Output folder to write autosave request files"
),
db_list: list[Path] = typer.Argument(
..., help="List of autosave req files to link "
),
):
"""
Convert DLS autosave DB template comments into autosave req files
"""
parse_templates(out_folder, db_list)


def parse_templates(out_folder: Path, db_list: list[Path]):
"""
DLS has 3 autosave levels
Expand Down

0 comments on commit d820461

Please sign in to comment.