mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:27:07 +00:00
Check for lineNameInfo when importing P1/11
This commit is contained in:
@@ -73,6 +73,12 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
lineNameInfo = final_p111.get("lineNameInfo")
|
lineNameInfo = final_p111.get("lineNameInfo")
|
||||||
pattern = final_p111.get("pattern")
|
pattern = final_p111.get("pattern")
|
||||||
|
if not lineNameInfo:
|
||||||
|
if not pattern:
|
||||||
|
print("ERROR! Missing final.p111.lineNameInfo in project configuration. Cannot import final P111")
|
||||||
|
throw Exception("Missing final.p111.lineNameInfo")
|
||||||
|
else:
|
||||||
|
print("WARNING! No `lineNameInfo` in project configuration (final.p111). You should add it to the settings.")
|
||||||
rx = None
|
rx = None
|
||||||
if pattern and pattern.get("regex"):
|
if pattern and pattern.get("regex"):
|
||||||
rx = re.compile(pattern["regex"])
|
rx = re.compile(pattern["regex"])
|
||||||
@@ -114,27 +120,27 @@ if __name__ == '__main__':
|
|||||||
file_info = dict(zip(pattern["captures"], match.groups()))
|
file_info = dict(zip(pattern["captures"], match.groups()))
|
||||||
file_info["meta"] = {}
|
file_info["meta"] = {}
|
||||||
|
|
||||||
if lineNameInfo:
|
if lineNameInfo:
|
||||||
basename = os.path.basename(physical_filepath)
|
basename = os.path.basename(physical_filepath)
|
||||||
fields = lineNameInfo.get("fields", {})
|
fields = lineNameInfo.get("fields", {})
|
||||||
fixed = lineNameInfo.get("fixed")
|
fixed = lineNameInfo.get("fixed")
|
||||||
try:
|
try:
|
||||||
parsed_line = fwr.parse_line(basename, fields, fixed)
|
parsed_line = fwr.parse_line(basename, fields, fixed)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
parsed_line = "Line format error: " + str(err)
|
parsed_line = "Line format error: " + str(err)
|
||||||
if type(parsed_line) == str:
|
if type(parsed_line) == str:
|
||||||
print(parsed_line, file=sys.stderr)
|
print(parsed_line, file=sys.stderr)
|
||||||
print("This file will be ignored!")
|
print("This file will be ignored!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_info = {}
|
file_info = {}
|
||||||
file_info["sequence"] = parsed_line["sequence"]
|
file_info["sequence"] = parsed_line["sequence"]
|
||||||
file_info["line"] = parsed_line["line"]
|
file_info["line"] = parsed_line["line"]
|
||||||
del(parsed_line["sequence"])
|
del(parsed_line["sequence"])
|
||||||
del(parsed_line["line"])
|
del(parsed_line["line"])
|
||||||
file_info["meta"] = {
|
file_info["meta"] = {
|
||||||
"fileInfo": parsed_line
|
"fileInfo": parsed_line
|
||||||
}
|
}
|
||||||
|
|
||||||
if pending:
|
if pending:
|
||||||
print("Skipping / removing final file because marked as PENDING", logical_filepath)
|
print("Skipping / removing final file because marked as PENDING", logical_filepath)
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
lineNameInfo = raw_p111.get("lineNameInfo")
|
lineNameInfo = raw_p111.get("lineNameInfo")
|
||||||
pattern = raw_p111.get("pattern")
|
pattern = raw_p111.get("pattern")
|
||||||
|
if not lineNameInfo:
|
||||||
|
if not pattern:
|
||||||
|
print("ERROR! Missing raw.p111.lineNameInfo in project configuration. Cannot import raw P111")
|
||||||
|
throw Exception("Missing raw.p111.lineNameInfo")
|
||||||
|
else:
|
||||||
|
print("WARNING! No `lineNameInfo` in project configuration (raw.p111). You should add it to the settings.")
|
||||||
rx = None
|
rx = None
|
||||||
if pattern and pattern.get("regex"):
|
if pattern and pattern.get("regex"):
|
||||||
rx = re.compile(pattern["regex"])
|
rx = re.compile(pattern["regex"])
|
||||||
@@ -96,14 +102,15 @@ if __name__ == '__main__':
|
|||||||
print("This file will be ignored!")
|
print("This file will be ignored!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_info = {}
|
file_info = {}
|
||||||
file_info["sequence"] = parsed_line["sequence"]
|
file_info["sequence"] = parsed_line["sequence"]
|
||||||
file_info["line"] = parsed_line["line"]
|
file_info["line"] = parsed_line["line"]
|
||||||
del(parsed_line["sequence"])
|
del(parsed_line["sequence"])
|
||||||
del(parsed_line["line"])
|
del(parsed_line["line"])
|
||||||
file_info["meta"] = {
|
file_info["meta"] = {
|
||||||
"fileInfo": parsed_line
|
"fileInfo": parsed_line
|
||||||
}
|
}
|
||||||
|
|
||||||
p111_data = p111.from_file(physical_filepath)
|
p111_data = p111.from_file(physical_filepath)
|
||||||
|
|
||||||
print("Saving")
|
print("Saving")
|
||||||
|
|||||||
Reference in New Issue
Block a user