From bcddea42364adfd1360cf4cd2120f23adfc592b0 Mon Sep 17 00:00:00 2001 From: giles knap Date: Tue, 17 Dec 2024 09:01:45 +0000 Subject: [PATCH] fix lint --- src/builder2ibek/__main__.py | 2 +- src/builder2ibek/convert.py | 2 +- src/builder2ibek/db2autosave.py | 4 ++-- src/builder2ibek/dbcompare.py | 16 ++++++++-------- .../{make_sample_yaml.sh => make_samples.sh} | 2 ++ tests/samples/sr03c-va-ioc-01.yaml | 7 +++++-- tests/test_file_conversion.py | 4 ++-- 7 files changed, 21 insertions(+), 16 deletions(-) rename tests/samples/{make_sample_yaml.sh => make_samples.sh} (72%) diff --git a/src/builder2ibek/__main__.py b/src/builder2ibek/__main__.py index a2c6dda..611dbed 100644 --- a/src/builder2ibek/__main__.py +++ b/src/builder2ibek/__main__.py @@ -34,7 +34,7 @@ def main( 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( + schema: str = typer.Option( "/epics/ibek-defs/ioc.schema.json", help="Generic IOC schema (added to top of the yaml output)", ), diff --git a/src/builder2ibek/convert.py b/src/builder2ibek/convert.py index adf41c2..4eaf54a 100644 --- a/src/builder2ibek/convert.py +++ b/src/builder2ibek/convert.py @@ -13,7 +13,7 @@ from builder2ibek.types import Entity, Generic_IOC -def convert_file(xml: Path, yaml: Path, schema: str) -> str: +def convert_file(xml: Path, yaml: Path, schema: str): def tidy_up(yaml): # add blank lines between major fields for field in [ diff --git a/src/builder2ibek/db2autosave.py b/src/builder2ibek/db2autosave.py index 2e6ec6a..4059039 100644 --- a/src/builder2ibek/db2autosave.py +++ b/src/builder2ibek/db2autosave.py @@ -26,8 +26,8 @@ def parse_templates(out_folder: Path, db_list: list[Path]): for db in db_list: text = db.read_text() - positions = set() - settings = set() + positions: set[str] = set() + settings: set[str] = set() for n in range(3): match n: case 0: diff --git a/src/builder2ibek/dbcompare.py b/src/builder2ibek/dbcompare.py index 56ff707..6b4b2a2 100644 --- a/src/builder2ibek/dbcompare.py +++ b/src/builder2ibek/dbcompare.py @@ -16,10 +16,10 @@ def compare_dbs( old_text = original.read_text() new_text = new.read_text() - old_set = set() + old_set: set[str] = set() for record in regex_record.finditer(old_text): old_set.add(f"{record.group(1)} {record.group(2)}") - new_set = set() + new_set: set[str] = set() for record in regex_record.finditer(new_text): new_set.add(f"{record.group(1)} {record.group(2)}") @@ -28,14 +28,14 @@ def compare_dbs( old_only_filtered = old_only.copy() new_only_filtered = new_only.copy() - for record in old_only: + for rec in old_only: for s in ignore: - if s in record: - old_only_filtered.remove(record) - for record in new_only: + if s in rec: + old_only_filtered.remove(rec) + for rec in new_only: for s in ignore: - if s in record: - new_only_filtered.remove(record) + if s in rec: + new_only_filtered.remove(rec) result = ( "Records in original but not in new:\n" diff --git a/tests/samples/make_sample_yaml.sh b/tests/samples/make_samples.sh similarity index 72% rename from tests/samples/make_sample_yaml.sh rename to tests/samples/make_samples.sh index c62b75c..6386972 100755 --- a/tests/samples/make_sample_yaml.sh +++ b/tests/samples/make_samples.sh @@ -8,3 +8,5 @@ for x in *.xml; do echo converting $x to $y builder2ibek xml2yaml $x --yaml $y done + +builder2ibek db-compare ./SR03C-VA-IOC-01_expanded.db ./sr03c-va-ioc-01.db --output ./compare.diff diff --git a/tests/samples/sr03c-va-ioc-01.yaml b/tests/samples/sr03c-va-ioc-01.yaml index f3db468..e85ebd3 100644 --- a/tests/samples/sr03c-va-ioc-01.yaml +++ b/tests/samples/sr03c-va-ioc-01.yaml @@ -29,6 +29,9 @@ entities: name: EPICS_CAS_BEACON_ADDR_LIST value: 172.23.194.105 + - type: autosave.Autosave + P: 'SR03C-VA-IOC-01:' + - type: asyn.AsynIP name: GCTLR_A_01_PORT port: 192.168.3.11:7002 @@ -1059,14 +1062,14 @@ entities: master: FV.MASTER name: FV.G8 - - type: terminalServer.Moxa + - type: terminalServer.Moxa16 HOST: 192.168.3.11 NCHANS: 16 P: SR03C-VA-TSERV-01 R: '' name: TSERV1 - - type: terminalServer.Moxa + - type: terminalServer.Moxa16 HOST: 192.168.3.12 NCHANS: 16 P: SR03C-VA-TSERV-02 diff --git a/tests/test_file_conversion.py b/tests/test_file_conversion.py index 3ed400e..403cbec 100644 --- a/tests/test_file_conversion.py +++ b/tests/test_file_conversion.py @@ -10,8 +10,8 @@ def test_convert(samples: Path): - samples = samples.glob("*.xml") - for sample_xml in samples: + all_samples = samples.glob("*.xml") + for sample_xml in all_samples: sample_yaml = Path(str(sample_xml.with_suffix(".yaml")).lower()) out_yaml = Path("/tmp") / sample_yaml.name