From 3efb92bfe141fd87fbc44394879ed81105d12250 Mon Sep 17 00:00:00 2001 From: tangkong Date: Thu, 27 Feb 2025 15:02:09 -0800 Subject: [PATCH 1/2] BUG: only add delay tag if there is a non-0 delay specified --- Scripts/alarm_csv2xml.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/alarm_csv2xml.py b/Scripts/alarm_csv2xml.py index fbe6084..cd83d78 100755 --- a/Scripts/alarm_csv2xml.py +++ b/Scripts/alarm_csv2xml.py @@ -44,9 +44,10 @@ def csvtoxml(infile, outfile, cname): desc = ET.SubElement(pv, 'description') desc.text = row['Description'] latch = ET.SubElement(pv, 'latching') - latch.text = row['Latch'].capitalize() if row['Latch'] else 'True' - delay = ET.SubElement(pv, 'delay') - delay.text = row['Delay'] + latch.text = row['Latch'].capitalize() if row['Latch'] else "True" + if "Delay" in row and row['Delay']: + delay = ET.SubElement(pv, 'delay') + delay.text = row['Delay'] if 'Filter' in row and row['Filter']: filter = ET.SubElement(pv, 'filter') filter.text = row['Filter'] From 4751ba85e08ab7dae92ebdef9479b9e5afec5379 Mon Sep 17 00:00:00 2001 From: tangkong Date: Thu, 27 Feb 2025 15:41:22 -0800 Subject: [PATCH 2/2] MNT: also ensure description does not produce empty tags, python-ify if statements --- Scripts/alarm_csv2xml.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Scripts/alarm_csv2xml.py b/Scripts/alarm_csv2xml.py index cd83d78..f792e3f 100755 --- a/Scripts/alarm_csv2xml.py +++ b/Scripts/alarm_csv2xml.py @@ -41,17 +41,18 @@ def csvtoxml(infile, outfile, cname): else: raise ValueError(f'Got unsupported protocol "{protocol}" in {pv_name}') pv.set('name', pv_name) - desc = ET.SubElement(pv, 'description') - desc.text = row['Description'] + if row.get('Description', False): + desc = ET.SubElement(pv, 'description') + desc.text = row['Description'] latch = ET.SubElement(pv, 'latching') latch.text = row['Latch'].capitalize() if row['Latch'] else "True" - if "Delay" in row and row['Delay']: + if row.get('Delay', False): delay = ET.SubElement(pv, 'delay') delay.text = row['Delay'] - if 'Filter' in row and row['Filter']: + if row.get('Filter', False): filter = ET.SubElement(pv, 'filter') filter.text = row['Filter'] - if 'Guidance' in row and row['Guidance']: + if row.get('Guidance', False): guidance = ET.SubElement(pv, 'guidance') guidance.text = row['Guidance']