Skip to content

Commit

Permalink
expanded fixvalidreferences option to apply at parse time if checkref…
Browse files Browse the repository at this point in the history
…erences is also set

Ref: proycon/flat#192
  • Loading branch information
proycon committed Oct 11, 2024
1 parent edb882d commit 6b4b3da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
build/*
docs/_autosummary/*
docs/build/*
env/
.env/
6 changes: 4 additions & 2 deletions folia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6331,6 +6331,9 @@ def parsexml(Class, node, doc, **kwargs):#pylint: disable=bad-classmethod-argume
if doc.debug >= 1: print("[FoLiA DEBUG] ...Unresolvable!",file=stderr)
if doc.checkreferences:
raise InvalidReference(id)
elif doc.checkreferences and doc.fixinvalidreferences:
print(f"[FoLiA WARNING] Dropping invalid reference (wref) to {id}!",file=stderr)
return None
else:
return WordReference(doc, id=id)

Expand Down Expand Up @@ -7288,8 +7291,7 @@ def __init__(self, *args, **kwargs):
mode: The mode for loading a document, is either ``folia.Mode.MEMORY``, in which the entire FoLiA Document will be loaded into memory. This is the default mode and the only mode in which documents can be manipulated and saved againor ``folia.Mode.XPATH``, in which the full XML tree will still be loaded into memory, but conversion to FoLiA classes occurs only when queried. This mode can be used when the full power of XPath is required.
checkreferences (bool): Check whether references are valid upon loading (default: True)
fixunassignedprocessor (bool): If set, fixes invalid FoLiA that does not explicitly assign a processor to an annotation when multiple processors are possible (and there is therefore no default). The last processor will be used in this case. (default: False)
fixinvalidereferences (bool): Do not serialise an invalid reference, remove the reference and output a comment instead. (default: False)
"""
fixinvalidreferences (bool): Do not serialise an invalid reference, remove the reference and output a comment instead. If checkreferences is set, this will apply at parse time and output warnings to standard error output instead (default: False)"""


self.version = kwargs.get('version', FOLIAVERSION)
Expand Down

0 comments on commit 6b4b3da

Please sign in to comment.