958c077da3
Cmds: Support --write-profile <filename>
...
Add an option which makes the program write profiling statistics in pstats format to a specified file.
Visualize e.g. with:
gprof2dot -f pstats <filename> -o <dotfile> dot -Tpng | display <dotfile>
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-06-05 16:58:26 +02:00
d2ec56336e
ArgsContainer: Add add_argument() function
...
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>
2025-06-04 04:55:32 +02:00
6e70529f7a
log.(add|rm)_capture_stream(): Add functions
...
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>
2025-06-03 15:25:44 +02:00
748b850532
log.set_level(): Return current flags
...
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>
2025-06-03 15:17:08 +02:00
cf122e44be
log.slog(): Support log flag "module"
...
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>
2025-06-01 15:14:48 +02:00
5ee88c1a81
cmd.Cmds: Support --backtrace
...
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>
2025-05-30 15:53:43 +02:00
b464f20e6c
stree.StringTree.find(): Add method
...
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>
2025-05-29 12:05:10 +02:00
a9fa274bb1
stree.StringTree: Add property path
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-29 12:04:52 +02:00
9c13381e7a
cast.cast_str_to_timedelta(): Add conversion method
...
Make cast.from_str() accept time strings.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-28 11:12:49 +02:00
296dde387c
cast.from_str(): Add as alias to cast_str()
...
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>
2025-05-28 11:11:11 +02:00
8f464fe278
Config: Add method __setitem__()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-20 13:11:14 +02:00
7cd94fa3db
Config: Add .root
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-20 13:10:53 +02:00
18117e4590
stree.StringTree: Add .parent and .root
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-20 13:09:58 +02:00
51f08d3dce
ArgsContainer: Add class
...
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>
2025-05-16 06:52:45 +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
4b4d8ebdb0
Config: Add property name
...
There's currently no way to access the root node content, add the property name for that.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-05-12 18:53:04 +02:00
20f713e6f7
Fix errors reported by mypy
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-04-29 11:54:56 +02:00
6835a569a5
query.Queries: Remove references to app
...
App is not a standardized interface, remove references to it.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-03-16 15:22:34 +01:00
34de9114c5
Config: Support glob_paths_env_key
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-03-12 13:37:32 +01:00
495cebd769
db.Session: Add
...
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>
2025-03-10 18:44:39 +01:00
841b5a3391
Fix errors reported by mypy
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-03-01 07:58:19 +01:00
5b71c081f4
schema.Table: Support property edit_columns
...
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>
2025-02-19 17:29:09 +01:00
7f2e0e3916
schema.Table: Add property default_sort_columns
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-17 12:22:26 +01:00
b33d9af302
schema.Table: Add add_child_row_location() and friends
...
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>
2025-02-15 16:30:14 +01:00
5ca775eb82
schema.Table: Add property add_row_location_rule and friends
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-15 11:43:00 +01:00
9b1650b58f
jwutils: Add Auth
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-14 14:29:30 +01:00
74902349b6
Config: Add method entries()
...
Config has no way to tell if a given path has children, so add the entries() method.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-15 08:20:53 +01:00
79a3696eaa
Config: Make branch() throw exception on inexistent path
...
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>
2025-02-15 08:19:25 +01:00
91d7517054
schema.Column: Add property translate
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-14 08:12:02 +01:00
ba1b7eda19
schema.Table: Add property relationships
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-13 08:35:40 +01:00
9685f07eb8
query.Queries: Add method keys()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-12 18:36:37 +01:00
173ff0ef5a
schema: Continue
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-04 10:27:38 +01:00
4cc9906055
db.query: Add Query, QueryResult, Queries
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-02 14:02:21 +01:00
2b061a6dc4
db: Add DataBase.py
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-02 15:58:52 +01:00
859bb8000f
Cmds / Cmd: Add comments and debug logging
...
Add some comments and a little debug logging to clarify operation.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-02 14:01:21 +01:00
fb907b0493
schema: Add utils
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-02-01 09:58:25 +01:00
c50c614f13
schema: Continue
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-30 20:34:44 +01:00
9cfcc1bd68
db.schema: Add location definition to API
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-30 14:26:43 +01:00
e688cd2364
Config: Support refuse_mode_mask
...
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>
2025-01-30 09:54:03 +01:00
17ab47e96a
Add db.schema framework
...
jw.db.schema is a set of classes meant as an interface to describe a database schema.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 10:18:57 +01:00
cc7aeeac31
misc: Add load_function()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-29 16:54:10 +01:00
e004f8ade7
db: Add TableIoHandler
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 14:27:27 +01:00
7399388f60
Fix errors reported by mypy
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-29 16:51:07 +01:00
bee3e28ff5
Config: Accept strings as value for glob_paths
...
Make Config's ctor accept strings as values for glob_paths, as opposed to lists. This covers the canonical case of one configuration file being passed.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-29 12:56:32 +01:00
2ec6e72cff
Cmds: Add parsed args as attribute
...
The parsed args container is passed to the run() function and friends for convenient use. Sometimes, though, the base classes or umbrella commands need to make use of it, too, even more so as they may define command line arguments via add_arguments(). However, run() or _run() or whatever is never called on them, neither any other callback, so make args available to them as a member variable.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-29 12:51:01 +01:00
055c008a33
Cmds: Make run() accept argv argument
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 20:27:25 +01:00
d5e268a03b
log: Add throw()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 10:17:27 +01:00
2462ad8c60
log: Add log_level()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 10:17:17 +01:00
ce347772dd
misc: Add debug logging to load_class()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 10:16:06 +01:00