diff --git a/README.md b/README.md index 933dee4..6717c04 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,26 @@ # builder2ibek -Conversion tool for DLS XML builder IOC instances to ibek ioc.yaml - -This is where you should write a short paragraph that describes what your module does, -how it does it, and why people should use it. +A tool suite for converting DLS XML builder projects to epics-containers ibek. Source | :---: | :---: PyPI | `pip install builder2ibek` Releases | -This is where you should put some images or code snippets that illustrate -some relevant examples. If it is a library then you might put some -introductory code here: +
╭─ Commands ───────────────────────────────────────────────────────────────────╮
+xml2yaml        Convert a builder XML IOC instance definition file into an   │
+                ibek YAML file                                               │
+beamline2yaml   Convert all IOCs in a BLXXI-SUPPORT project into a set of    │
+                ibek services folders (TODO)                                 │
+autosave        Convert DLS autosave DB template comments into autosave req  │
+                files                                                        │
+db-compare      Compare two DB files and output the differences              │
+╰──────────────────────────────────────────────────────────────────────────────╯
+
+ +```bash +builder2ibek ```python from builder2ibek import __version__ diff --git a/pyproject.toml b/pyproject.toml index 41edba0..23aa299 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,6 @@ dev = [ [project.scripts] builder2ibek = "builder2ibek.__main__:cli" -db2autosave = "builder2ibek.db2autosave:cli" [project.urls] GitHub = "https://github.com/epics-containers/builder2ibek" diff --git a/src/builder2ibek/__main__.py b/src/builder2ibek/__main__.py index 39b0245..88d917f 100644 --- a/src/builder2ibek/__main__.py +++ b/src/builder2ibek/__main__.py @@ -9,6 +9,7 @@ from builder2ibek.builder import Builder from builder2ibek.convert import dispatch from builder2ibek.db2autosave import parse_templates +from builder2ibek.dbcompare import compare_dbs cli = typer.Typer() yaml = YAML() @@ -42,6 +43,10 @@ def xml2yaml( help="Generic IOC schema (added to top of the yaml output)", ), ): + """ + Convert a builder XML IOC instance definition file into an ibek YAML file + """ + def tidy_up(yaml): # add blank lines between major fields for field in [ @@ -83,16 +88,13 @@ def beamline2yaml( output: Path = typer.Argument(..., help="Output root folder"), ): """ - Convert a beamline's IOCs from builder XML to ibek YAML + Convert all IOCs in a BLXXI-SUPPORT project into a set of ibek services + folders (TODO) """ typer.echo("Not implemented yet") raise typer.Exit(code=1) -if __name__ == "__main__": - cli() - - @cli.command() def autosave( out_folder: Path = typer.Option( @@ -106,3 +108,16 @@ def autosave( Convert DLS autosave DB template comments into autosave req files """ parse_templates(out_folder, db_list) + + +@cli.command() +def db_compare(original: Path, new: Path): + """ + Compare two DB files and output the differences + """ + + compare_dbs(original, new) + + +if __name__ == "__main__": + cli() diff --git a/src/builder2ibek/dbcompare.py b/src/builder2ibek/dbcompare.py new file mode 100644 index 0000000..c9aeea1 --- /dev/null +++ b/src/builder2ibek/dbcompare.py @@ -0,0 +1,17 @@ +import re +from pathlib import Path + +regex_record = [ + re.compile(rf'# *% *autosave *{n} *(.*)[\s\S]*?record *\(.*, *"?([^"]*)"?\)') + for n in range(3) +] + + +def compare_dbs(original: Path, new: Path): + """ + validate that two DBs have the same set of records + + used to ensure that an IOC converted to epics-containers has the same + records as the original builder IOC + """ + pass