From de9469d12ac89d64eda64c4a4d303a03628db1d2 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 25 Oct 2023 11:35:53 +0200 Subject: [PATCH] Stupid fix to make reccuring blocks readable and writable --- src/hsd/dict.py | 7 +++++++ src/hsd/parser.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/hsd/dict.py b/src/hsd/dict.py index 847aab0..65c78af 100644 --- a/src/hsd/dict.py +++ b/src/hsd/dict.py @@ -103,6 +103,13 @@ def open_tag(self, tagname, attrib, hsdattrib): self._parentblocks.append(self._curblock) self._curblock = {} + def retrieve_tag(self, tagname): + tagname = tagname.strip() + key = tagname.lower() if self._lower_tag_names else tagname + for parentblock in self._parentblocks[-1::-1]: + if key in parentblock: + self._curblock.update(parentblock[key]) + break def close_tag(self, tagname): attrib, hsdattrib = self._attribs.pop(-1) diff --git a/src/hsd/parser.py b/src/hsd/parser.py index 4ab36d8..dd89bec 100644 --- a/src/hsd/parser.py +++ b/src/hsd/parser.py @@ -128,6 +128,9 @@ def _parse(self, line): self._closetag() self._after_equal_sign = False elif not self._inside_attrib: + if before.strip().startswith("$"): + self._eventhandler.retrieve_tag(before) + before = "" self._buffer.append(before) elif before.strip(): self._error(SYNTAX_ERROR, (self._currline, self._currline))