Skip to content

Commit

Permalink
add db compare
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 15, 2024
1 parent d820461 commit 4af36b9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <https://github.com/epics-containers/builder2ibek>
:---: | :---:
PyPI | `pip install builder2ibek`
Releases | <https://github.com/epics-containers/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:
<pre><font color="#AAAAAA">╭─ Commands ───────────────────────────────────────────────────────────────────╮</font>
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b>xml2yaml </b></font> Convert a builder XML IOC instance definition file into an │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b> </b></font> ibek YAML file │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b>beamline2yaml </b></font> Convert all IOCs in a BLXXI-SUPPORT project into a set of │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b> </b></font> ibek services folders (TODO) │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b>autosave </b></font> Convert DLS autosave DB template comments into autosave req │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b> </b></font> files │
<font color="#AAAAAA">│ </font><font color="#2AA1B3"><b>db-compare </b></font> Compare two DB files and output the differences │
<font color="#AAAAAA">╰──────────────────────────────────────────────────────────────────────────────╯</font>
</pre>

```bash
builder2ibek

```python
from builder2ibek import __version__
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dev = [

[project.scripts]
builder2ibek = "builder2ibek.__main__:cli"
db2autosave = "builder2ibek.db2autosave:cli"

[project.urls]
GitHub = "https://github.com/epics-containers/builder2ibek"
Expand Down
25 changes: 20 additions & 5 deletions src/builder2ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 [
Expand Down Expand Up @@ -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(
Expand All @@ -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()
17 changes: 17 additions & 0 deletions src/builder2ibek/dbcompare.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4af36b9

Please sign in to comment.