Commit graph

19 commits

Author SHA1 Message Date
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
3cd7926693 stree.parse(): Beautify debug logging
Signed-off-by: Jan Lindemann <jan@janware.com>
2024-10-06 17:13:41 +02: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
020bb970bd stree/serdes.py: Add support for kwarg "root_content"
parse() and read() up to present automatically set the root content
of a StringTree object to "root". This can now be optionally defined
by the "root_content" keyword argument.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-04 11:14:33 +02:00
1f122fae82 Rename the MODDIR makefile variable to JWBDIR
Rename the omnipresent MODDIR variable to JWBDIR, since that's more to the
point.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-29 23:32:20 +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
838ac06ebb Fix: StringTree misparsed key = "val # blah"
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-26 21:25:01 +01:00
3d93d534db StringTree: Respect quoted quotes
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-22 09:34:26 +01:00
5a87040e10 stree/serdes.py: Allow quoted = in rhs of assignment
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-12 16:08:34 +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
6ca2eeef61 StringTree parser: Add support for comments
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-02 11:47:04 +01:00
214c222002 Add StringTree and friends
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-01 13:26:10 +01:00