Commit graph

135 commits

Author SHA1 Message Date
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
ddb1fd0eb4 Add db.rows
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 08:11:54 +01:00
8c0b975e1b Config: Mutually exclude loading from tree or files
Initializing Config from a StringTree object doesn't stop it from
looking for config files to read. Stop that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 08:05:16 +01: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
84a4053157 Add class Config
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-20 11:39:56 +01:00
224a16ec71 Cmds: Add TODO Rename to App
There's an ungreppable TODO remark in Cmds about renaming the class
to App, make it greppable.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-18 20:53:45 +01:00
45b5a8fb5a log: Add prio_gets_logged()
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-18 16:42:33 +01:00
24bfa0f806 stree/serdes: Support -include lines
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-16 13:44:09 +01:00
a0234e7d54 Add module jwutils.cast
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-16 12:39:20 +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
381514ab2c misc: Add load_class()
Add load_class() to complement load_object(), returning the class as
opposed to instantiated object.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-16 10:51:28 +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
385edd7169 StopWatch: Fix compilation error
Signed-off-by: Jan Lindemann <jan@janware.com>
2024-12-03 13:34:26 +01:00
4b8d67b8ee Cmd.add_subcommand(): Add support for passing cmd argument as string
Signed-off-by: Jan Lindemann <jan@janware.com>
2024-12-03 13:34:25 +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