Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to make recurring blocks readable and writable #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/hsd/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/hsd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down