2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

more correct error message

This commit is contained in:
Philip Sargent 2023-08-04 16:08:07 +03:00
parent 3b9a2b990d
commit c8430d1ff7

View File

@ -310,13 +310,13 @@ def getXML(text, itemname, minItems=1, maxItems=None, context=""):
Should throw exception rather than producing error message here,
then handle exception in calling routine where it has the context.
This always succeeds, but it produices error message on the terminal and in the
DatIssues log.
This always succeeds, but it produces error message on the terminal and in the
DataIssues log.
"""
items = re.findall("<%(itemname)s>(.*?)</%(itemname)s>" % {"itemname": itemname}, text, re.S)
if len(items) < minItems:
message = (
" ! %(count)i x %(itemname)s found, at least %(min)i expected. Load ABORT. "
" ! %(count)i x %(itemname)s found, at least %(min)i expected. Load may ABORT. "
% {"count": len(items), "itemname": itemname, "min": minItems}
+ " in file "
+ context
@ -326,7 +326,7 @@ def getXML(text, itemname, minItems=1, maxItems=None, context=""):
if maxItems is not None and len(items) > maxItems:
message = (
" ! %(count)i x %(itemname)s found, no more than %(max)i expected in this XML unit. Load ABORT. "
" ! %(count)i x %(itemname)s found, no more than %(max)i expected in this XML unit. Load may ABORT. "
% {"count": len(items), "itemname": itemname, "max": maxItems}
+ " in file "
+ context