Skip to content

Commit 426c119

Browse files
committed
remove the octetCount in the txt and from the CI/CD
1 parent 898145c commit 426c119

File tree

2 files changed

+4280
-4310
lines changed

2 files changed

+4280
-4310
lines changed

scripts/create_master_lists.py

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ def __init__(self,outfile,headers):
2323

2424

2525
def write_row(self,row):
26-
# remove any keys not in 'fieldnames' to avoid ValueError
27-
for key in list(row.keys()):
28-
if key not in self.csvwriter.fieldnames:
29-
del row[key]
26+
3027
self.csvwriter.writerow(row)
3128

3229

@@ -70,29 +67,8 @@ def close(self):
7067

7168
xmlfile.write(xml)
7269

73-
74-
def parse_octet_length(octet_str):
75-
# attempt to compute the length for simple cases
76-
# fallback if expression is more complex
77-
if any(sym in octet_str for sym in ['(', ')', '+', '*', 'ND', 'NF', 'n']):
78-
return ""
70+
7971

80-
total_length = 0
81-
parts = [p.strip() for p in octet_str.split(',')]
82-
for p in parts:
83-
range_match = re.match(r'^(\d+)-(\d+)$', p)
84-
single_match = re.match(r'^(\d+)$', p)
85-
if range_match:
86-
start = int(range_match.group(1))
87-
end = int(range_match.group(2))
88-
total_length += (end - start + 1)
89-
elif single_match:
90-
total_length += 1
91-
else:
92-
return ""
93-
return str(total_length)
94-
95-
9672
def process_files(files,pattern,writers,title_prefix):
9773

9874
rows=[]
@@ -165,13 +141,6 @@ def process_files(files,pattern,writers,title_prefix):
165141
rows = [row for *_,row in decorated]
166142

167143

168-
169-
# For Template rows, add computed OctetNumer
170-
if pattern == 'GRIB2_Template':
171-
for row in rows:
172-
octet_str = row.get("OctetNo", "")
173-
row["OctetCount"] = parse_octet_length(octet_str)
174-
175144
for row in rows:
176145
for writer in writers:
177146
writer.write_row(row)
@@ -207,12 +176,13 @@ def process_files(files,pattern,writers,title_prefix):
207176
# Template tables
208177
template_files = load_files("GRIB2_Template",basedir=".")
209178

210-
# Added "OctetCount" to both fieldnames
211-
fieldnames=["Title_en","OctetNo","Contents_en","Note_en","noteIDs","codeTable","flagTable","OctetCount","Status"]
179+
fieldnames=["Title_en","OctetNo","Contents_en","Note_en","noteIDs","codeTable","flagTable","Status"]
212180
csv_writer = CSVWriter("txt/Template.txt",fieldnames)
213181

214182
xml_elements=["Title_en","OctetNo","Contents_en","Note_en","noteIDs","codeTable","flagTable","Status"]
215183
xml_writer = XMLWriter("xml/Template.xml",xml_elements,"GRIB2_Template_en")
216184

217185
writers = [csv_writer,xml_writer]
218186
process_files(template_files,"GRIB2_Template",writers,"Identification template")
187+
188+

0 commit comments

Comments
 (0)