add_argument() at the face of it looks much like
ArgumentParser.add_argument(), but is a function, not a class method.
It takes the ArgsContainer|ArgParser instance as first argument, then
decides what type it is, and proceeds to use this knowledge to decide
whether or not the argument to be added already has a definition.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add functions log.(add|rm)_capture_stream(). The functions are meant
to capture everything passed to syslog into the stream objects
installed by it. Not sure about future semantics changes:
add_capture_stream() takes a currently unused flags argument, and it
suppresses everything else logged until the stream is removed again.
Signed-off-by: Jan Lindemann <jan@janware.com>
Make log.set_level() return the flags that were set before setting
the flags passed as argument.
Support None as flags argument, in which case it doesn't change
anything and only returns the currently set flags.
Signed-off-by: Jan Lindemann <jan@janware.com>
If module is present in the log flags string, the module is prepended
to each log message. The length of the module prefix can be set via
the new set_module_name_length() function.
Signed-off-by: Jan Lindemann <jan@janware.com>
Wrap all execution in try-block, don't raise in except block unless
--backtrace is passed to the command line.
Signed-off-by: Jan Lindemann <jan@janware.com>
StringTree.find(key, val) (and Config.find(), for that matter)
returns a list of paths with sections containing children matching
key / val pairs. One of them can be None, which acts as a wildcard.
Signed-off-by: Jan Lindemann <jan@janware.com>
Using cast.from_str('blah') seems more logical than cast.cast_str(),
so add that alias and see how it fares.
Signed-off-by: Jan Lindemann <jan@janware.com>
ArgsContainer provides an interface similar to
argparse.ArgumentParser and can be used as a drop-in replacement when
fishing for arguments.
Signed-off-by: Jan Lindemann <jan@janware.com>
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>
Add database session API to db. This is a breaking change, because
from this commit on, a session object has to be passed to every
query.
This commit also removes any reference to Cmds / App objects. An
instantiated database object can be worked with outside of an App.
Signed-off-by: Jan Lindemann <jan@janware.com>
Support property edit_columns, intended to populate forms where rows
are created or edited, defaulting to log_columns.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add the following methods:
add_child_row_location(self, parent_table: Union[Self, str], **kwargs) -> Optional[str]
add_child_row_location_rules(self) -> Iterable[str]
add_child_row_location_rule(self, child_table: Union[Self, str]) -> Optional[str]
These are meant to be called from different pieces of code:
- add_child_row_location() is meant to be used where the parent is
rendered, to display a link to adding another child
- add_child_row_location_rules() and add_child_row_location_rule()
are meant to be invoked where processing is going to be done, i.e.
likely code rendering child row content
Signed-off-by: Jan Lindemann <jan@janware.com>
Config.branch(path) just silently returns the entire tree if path
doesn't exist in the config. Fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
refuse_mode_mask can be passed to the constructor and determines
which permission bits need to be absent from config file modes if
they smell like they contain secrets.
Signed-off-by: Jan Lindemann <jan@janware.com>