Commit 91a3d272 authored by Phil Jones's avatar Phil Jones

Explicitly disallow multiple parse_legacy calls.

These didn't work anyway, as node names are lost after the parse is
completed.

Closes #247.
parent 0d252082
......@@ -66,6 +66,14 @@ def parse_legacy(text, model=None, ignored_blocks=None):
:class:`.Model`
The parsed model.
"""
if model:
# Newly-created models contain an fsig, so we need to account for that
if len(model.elements) > 1:
raise ValueError(
"Legacy parsing of extra commands with an existing model is unsupported. "
"Please switch to the new syntax, or only call 'parse_legacy' on a complete kat"
"file."
)
parser = LegacyKatParser()
return parser.parse(text, model=model, ignored_blocks=ignored_blocks)
......@@ -90,6 +98,14 @@ def parse_legacy_file(path, model=None, ignored_blocks=None):
:class:`.Model`
The parsed model.
"""
if model:
# Newly-created models contain an fsig, so we need to account for that
if len(model.elements) > 1:
raise ValueError(
"Legacy parsing of extra commands with an existing model is unsupported. "
"Please switch to the new syntax, or only call 'parse_legacy' on a complete kat"
"file."
)
parser = LegacyKatParser()
return parser.parse_file(path, model=model, ignored_blocks=ignored_blocks)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment