Skip to content

Commit

Permalink
allowing garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Aug 29, 2023
1 parent c97c32b commit c6e0891
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docker-qgis/process_projectfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from qgis.PyQt.QtGui import QColor

logger = logging.getLogger("PROCPRJ")
# Non-blocking, streaming XML parser
parser = ElementTree.XMLPullParser(["start", "end"])


class ProjectFileNotFoundException(BaseException):
Expand Down Expand Up @@ -45,13 +43,16 @@ def check_valid_project_file(project_filename: Path) -> None:
raise ProjectFileNotFoundException(project_filename=project_filename)

if project_filename.suffix == ".qgs":
# Non-blocking, streaming XML parser
parser = ElementTree.XMLPullParser(["start", "end"])

with open(project_filename, "rb") as f:
parser.feed(f.read())

last_visited_node_tag = ""
try:
for event, node in parser.read_events():
# traverse the stream in a non-blocking way, raising on the first
# parse error found
# traverse the stream, raising on the first parse error found
last_visited_node_tag = node.tag
except ElementTree.ParseError as err:
raise InvalidXmlFileException(
Expand Down

0 comments on commit c6e0891

Please sign in to comment.