Commit graph

19 commits

Author SHA1 Message Date
18117e4590 stree.StringTree: Add .parent and .root
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-20 13:09:58 +02:00
2bad14a891 stree.StringTree: Fix logging typo
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-16 06:52:22 +02:00
d30c41b03d stree.StringTree.py.__set(): Disable assert self.content != str(content)
There's an assertion in StringTree.py.__set(), assert self.content !=
str(content), which often triggers. Not sure what the idea behind the
assertion was, disable it.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-12 18:57:16 +02:00
64ce94b142 String Tree: Fix order of overwrites
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 07:18:50 +01:00
126ecbb411 StringTree: Beautify debug logging
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 05:08:50 +01:00
57ff96608b StringTree.value(): Add keyword-argument default
Add argument default to StringTree.value(), defaulting to None, doing
the obvious.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-16 10:53:09 +01:00
3a7fb50979 Apply monkeytype traces
Run

       monkeytype run jw-acc.py --log-level debug db import --format mdb-json-dir dbs
       monkeytype list-modules | grep ^jw | while read m; do
               monkeytype apply $m
       done

and fix the fallout.

Signed-off-by: Jan Lindemann <jan@janware.com>
2024-12-15 15:35:29 +01:00
08045442e2 StringTree: Fix exception in child_list()
child_list() throws an exception saying that <str> has no to_list()
method. No, it hasn't. No idea how this has even worked at all, ever.

Signed-off-by: Jan Lindemann <jan@janware.com>
2024-10-06 17:04:25 +02:00
85672d6cf3 StringTree.value(): Add optional path argument
As opposed to the C++ variant, StringTree.value() doesn't take a path
argument, but only returns the value of the node it's called on.
Change this. Returns None if the path is not found.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-18 08:38:34 +02:00
77d43aebad Add type annotations from monkeytype + jw-devops/test
Add type annotations as generated by monkeytype and jw-devops/test, plus some
hand editing to satisfy both monkeytype and mypy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-10 17:55:36 +02:00
952bf4a4e1 Fix Python errors reported by mypy
This commit fixes Python errors and warnings reported by static type checking
with mypy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-10 14:17:15 +02:00
fb6b205440 StringTree.__getitem__(): Return value child
StringTree.__getitem__() returned the node, now return its value
child instead. That's nicer and closer to the expected behaviour, as
it supports StringTree usage as a key-value store for configuration
or so. It breaks the existing API, but I think I have fixed the only
pace where it was used: jw-grammar/grammar.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-05 14:23:59 +02:00
dc532704d0 StringTree: Add support for adding StringTree children
Add support for adding children of type StringTree. If a StringTree
argument is passed to .add(), this should do the right thing. It
makes use of the newly added .__add_children() method and involves
quite a bit of hairy case distinctions.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-04 11:35:26 +02:00
dead9d9561 StringTree: add child_list()
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-04 11:31:25 +02:00
160667b6a9 StringTree: Re-implement __str__()
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-04 11:29:14 +02:00
1c0c5ab884 Attempt to support parsing full lines into StringTree
This commit tries to add support for the

  [section]
  first line
  second line

syntax, i.e. non-assignments, without equal sign. Half-baked, but
still better than before. Also support some more Python 3, i.e.
dict.items() instead of iteritems()

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-05-19 13:15:27 +00:00
3d93d534db StringTree: Respect quoted quotes
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-22 09:34:26 +01:00
7007c894b8 StringTree fix: Comments were not ignored in quotes
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-05 16:35:41 +01:00
214c222002 Add StringTree and friends
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-01 13:26:10 +01:00