2026-06-10 13:28:35 +02:00
|
|
|
from __future__ import annotations
|
2025-02-14 14:29:30 +01:00
|
|
|
|
|
|
|
|
import abc
|
|
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
from enum import Enum, Flag, auto
|
2026-11-25 11:58:22 +01:00
|
|
|
from typing import TYPE_CHECKING, Any, Self, Sequence, TypeAlias, cast, override
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
from ..Config import Config
|
|
|
|
|
from ..enum_helper import kebab_to_pascal
|
|
|
|
|
from ..log import ERR, WARNING, log
|
2026-06-10 07:22:46 +02:00
|
|
|
from ..misc import load_object
|
2026-07-13 19:35:49 +02:00
|
|
|
from ..stree.StringTree import StringTree
|
2025-02-14 14:29:30 +01:00
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
if TYPE_CHECKING:
|
2026-07-24 21:44:20 +02:00
|
|
|
from typing import Mapping
|
2026-06-10 13:28:35 +02:00
|
|
|
|
|
|
|
|
class Access(Enum): # export
|
|
|
|
|
Read = auto()
|
2025-02-14 14:29:30 +01:00
|
|
|
Modify = auto()
|
|
|
|
|
Create = auto()
|
|
|
|
|
Delete = auto()
|
|
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
class ProjectFlags(Flag): # export
|
|
|
|
|
NoFlags = auto()
|
2025-06-05 20:48:14 +02:00
|
|
|
Contributing = auto()
|
2026-06-10 13:28:35 +02:00
|
|
|
Active = auto()
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-26 18:53:13 +02:00
|
|
|
class Kind(Flag):
|
2026-07-13 19:35:49 +02:00
|
|
|
Group = auto()
|
|
|
|
|
User = auto()
|
2026-07-26 18:53:13 +02:00
|
|
|
Both = Group | User
|
2025-02-14 14:29:30 +01:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
class Entity(abc.ABC): # export
|
|
|
|
|
|
2026-11-25 11:58:22 +01:00
|
|
|
@override
|
|
|
|
|
def __eq__(self, other: Any) -> bool:
|
|
|
|
|
if not isinstance(other, Entity):
|
|
|
|
|
return NotImplemented
|
|
|
|
|
return (self.kind, self.name) == (other.kind, other.name)
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
def __hash__(self) -> int:
|
|
|
|
|
return hash((self.kind, self.name))
|
|
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
@abc.abstractmethod
|
|
|
|
|
def _kind(self) -> Kind:
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def kind(self) -> Kind:
|
|
|
|
|
return self._kind()
|
2026-07-07 18:44:58 +02:00
|
|
|
|
2025-02-14 14:29:30 +01:00
|
|
|
@abc.abstractmethod
|
|
|
|
|
def _name(self) -> str:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
2025-02-14 14:29:30 +01:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def name(self) -> str:
|
|
|
|
|
return self._name()
|
|
|
|
|
|
2025-06-05 20:48:14 +02:00
|
|
|
def _display_name(self) -> str:
|
|
|
|
|
return self._name()
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def display_name(self) -> str:
|
|
|
|
|
return self._display_name()
|
|
|
|
|
|
|
|
|
|
def _email(self) -> str:
|
2026-07-04 11:55:56 +02:00
|
|
|
return 'no-email@example.com'
|
2025-06-05 20:48:14 +02:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def email(self) -> str:
|
|
|
|
|
return self._email()
|
|
|
|
|
|
2026-07-04 11:55:56 +02:00
|
|
|
@abc.abstractmethod
|
|
|
|
|
def _groups(self) -> Sequence[Group]:
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def groups(self) -> Sequence[Group]:
|
|
|
|
|
return self._groups()
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
2026-07-13 19:35:49 +02:00
|
|
|
def _projects(self, flags: ProjectFlags) -> Sequence[str]:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
|
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def projects(self, flags: ProjectFlags) -> Sequence[str]:
|
|
|
|
|
return self._projects(flags)
|
|
|
|
|
|
|
|
|
|
User: TypeAlias = Entity
|
|
|
|
|
Group: TypeAlias = Entity
|
|
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
class Auth(abc.ABC): # export
|
2025-06-05 20:48:14 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
2026-07-13 19:35:49 +02:00
|
|
|
def load(
|
|
|
|
|
cls,
|
|
|
|
|
conf: Config | dict[str, Any] | StringTree,
|
|
|
|
|
base_type: type | None = None,
|
|
|
|
|
tp: str | None = None,
|
|
|
|
|
class_name_filter: str | None = None,
|
mypy: Fix disallow_incomplete_defs fallout
Add parameter and return type annotations to untyped functions all
over the package:
- ldap.py: Add return types to Config properties (ldap_uri, bind_dn,
bind_pw, base_dn), Connection.__init__, add, delete, walk, find,
__oc_recurse_to_top, object_class_path, and inner callbacks
- cast.py: Add Any import, add return type annotations to
cast_str_to_bool, guess_type, from_str, from_env, cast_str, and
parameter type annotations where missing
- Table.py:
- __init__ (schema: Schema)
- __eq__ (rhs: Any)
- _column_data_type (name: str)
- _column_default (name: str)
- column_default (name: str)
- foreign_keys_to_parent_table (parent_table: Any)
- misc.py:
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- multi_regex_edit (spec: Any)
- dump_dict (*args: Any, **kwargs: Any)
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- dump (*args: Any, **kwargs: Any)
- MapAttr2Shape.py, ShuntingYard.py, Queries.py:
- Add parameter and return type annotations to fix disallow_incomplete_defs:
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- Queries.py: _run, _register, name property, __getitem__, keys, load, add, _add
- Add parameter and return type annotations:
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- auth/Auth.py: load, conf, _entity, projects
- auth/ldap/Auth.py: __init__, _create_entity
- Fix parameter type annotations:
- rows_check_not_null: keys: str | list[str], stat_key: str | None, caller: Any
- rows_dumps: lead: str | list[str] | None, tablefmt: str | None
- rows_dump: heading: str | None, lead: str | list[str] | None, tablefmt: str | None
- Table.py: column_default, add_row_location, add_child_row_location
- CompositeForeignKey.py: __table, parent_column, child_column
- TableIoHandler.py: _load, _store, load
- Query.py: _register, register, parent property
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- MapAttr2Shape.py, auth/ldap/Auth.py, Query.py:
- MapAttr2Shape.py: Add None check for id, add None check for graph
- auth/ldap/Auth.py: Add Any import, fix __init__ and _create_entity
- Query.py: Fix _add, run, parent signatures
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- Config.py: dump
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- ShellCmd.py: __init__
- auth/Auth.py: load, __init__
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- auth/ldap/Auth.py: Entity.__init__, Auth.__init__, _create_entity
- cast.py: guess_type
- DataBase.py: _create_session, _delete_session
- TableIoHandler.py: load
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
- ldap.py: Config.__get__, Config properties, Connection methods, inner callbacks
- misc.py: get_derived_classes, load_classes, load_class_names, load_object,
multi_regex_edit, dump_dict, dump
- multi_key_dict.py: items
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 22:34:10 +02:00
|
|
|
module_path: list[str] = ['jwutils.auth.{type}.Auth'],
|
|
|
|
|
module_extra_path: list[str] = [],
|
|
|
|
|
*args: Any,
|
|
|
|
|
**kwargs: Any,
|
2026-07-13 19:35:49 +02:00
|
|
|
) -> Self:
|
|
|
|
|
|
|
|
|
|
# == Prepare arguments
|
|
|
|
|
|
|
|
|
|
# -- conf
|
2026-07-13 13:54:52 +02:00
|
|
|
if isinstance(conf, dict):
|
|
|
|
|
conf = StringTree.from_dict(conf)
|
|
|
|
|
if isinstance(conf, StringTree):
|
|
|
|
|
conf = Config(tree = conf)
|
2026-07-13 19:35:49 +02:00
|
|
|
|
|
|
|
|
# -- tp
|
|
|
|
|
if tp is None:
|
2025-10-13 12:45:51 +02:00
|
|
|
val = conf.get('type')
|
|
|
|
|
if val is None:
|
2026-06-10 13:28:35 +02:00
|
|
|
msg = 'No type specified in auth configuration'
|
2025-09-12 08:25:16 +02:00
|
|
|
conf.dump(ERR, msg)
|
|
|
|
|
raise Exception(msg)
|
2025-10-13 12:45:51 +02:00
|
|
|
tp = val
|
2025-02-14 14:29:30 +01:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
# -- class_name_filter
|
|
|
|
|
if class_name_filter is None:
|
|
|
|
|
class_name_filter = 'Auth'
|
|
|
|
|
|
|
|
|
|
# -- base_type
|
|
|
|
|
if base_type is None:
|
|
|
|
|
base_type = cls
|
|
|
|
|
|
|
|
|
|
# -- Strings path and class_name_filter
|
|
|
|
|
Type = kebab_to_pascal(tp)
|
|
|
|
|
macros = {'type': tp, 'Type': Type}
|
|
|
|
|
path = [p.format(**macros) for p in module_path + module_extra_path]
|
|
|
|
|
class_name_filter = class_name_filter.format(**macros)
|
|
|
|
|
|
|
|
|
|
# == Do it
|
2026-07-24 21:44:20 +02:00
|
|
|
return cast(
|
|
|
|
|
'Self',
|
|
|
|
|
load_object(path, base_type, class_name_filter, conf, *args, **kwargs)
|
2026-07-13 19:35:49 +02:00
|
|
|
)
|
|
|
|
|
|
mypy: Fix disallow_incomplete_defs fallout
Add parameter and return type annotations to untyped functions all
over the package:
- ldap.py: Add return types to Config properties (ldap_uri, bind_dn,
bind_pw, base_dn), Connection.__init__, add, delete, walk, find,
__oc_recurse_to_top, object_class_path, and inner callbacks
- cast.py: Add Any import, add return type annotations to
cast_str_to_bool, guess_type, from_str, from_env, cast_str, and
parameter type annotations where missing
- Table.py:
- __init__ (schema: Schema)
- __eq__ (rhs: Any)
- _column_data_type (name: str)
- _column_default (name: str)
- column_default (name: str)
- foreign_keys_to_parent_table (parent_table: Any)
- misc.py:
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- multi_regex_edit (spec: Any)
- dump_dict (*args: Any, **kwargs: Any)
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- dump (*args: Any, **kwargs: Any)
- MapAttr2Shape.py, ShuntingYard.py, Queries.py:
- Add parameter and return type annotations to fix disallow_incomplete_defs:
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- Queries.py: _run, _register, name property, __getitem__, keys, load, add, _add
- Add parameter and return type annotations:
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- auth/Auth.py: load, conf, _entity, projects
- auth/ldap/Auth.py: __init__, _create_entity
- Fix parameter type annotations:
- rows_check_not_null: keys: str | list[str], stat_key: str | None, caller: Any
- rows_dumps: lead: str | list[str] | None, tablefmt: str | None
- rows_dump: heading: str | None, lead: str | list[str] | None, tablefmt: str | None
- Table.py: column_default, add_row_location, add_child_row_location
- CompositeForeignKey.py: __table, parent_column, child_column
- TableIoHandler.py: _load, _store, load
- Query.py: _register, register, parent property
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- MapAttr2Shape.py, auth/ldap/Auth.py, Query.py:
- MapAttr2Shape.py: Add None check for id, add None check for graph
- auth/ldap/Auth.py: Add Any import, fix __init__ and _create_entity
- Query.py: Fix _add, run, parent signatures
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- Config.py: dump
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- ShellCmd.py: __init__
- auth/Auth.py: load, __init__
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- auth/ldap/Auth.py: Entity.__init__, Auth.__init__, _create_entity
- cast.py: guess_type
- DataBase.py: _create_session, _delete_session
- TableIoHandler.py: load
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
- ldap.py: Config.__get__, Config properties, Connection methods, inner callbacks
- misc.py: get_derived_classes, load_classes, load_class_names, load_object,
multi_regex_edit, dump_dict, dump
- multi_key_dict.py: items
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 22:34:10 +02:00
|
|
|
def __init__(self, conf: Config, *args: Any, **kwargs: Any) -> None:
|
2026-07-13 19:35:49 +02:00
|
|
|
super().__init__(*args, **kwargs)
|
2025-02-14 14:29:30 +01:00
|
|
|
self.__conf = conf
|
2026-07-13 19:35:49 +02:00
|
|
|
self.__base_entity_by_email: dict[str, Entity] | None = None
|
2025-02-14 14:29:30 +01:00
|
|
|
|
|
|
|
|
@property
|
mypy: Fix disallow_incomplete_defs fallout
Add parameter and return type annotations to untyped functions all
over the package:
- ldap.py: Add return types to Config properties (ldap_uri, bind_dn,
bind_pw, base_dn), Connection.__init__, add, delete, walk, find,
__oc_recurse_to_top, object_class_path, and inner callbacks
- cast.py: Add Any import, add return type annotations to
cast_str_to_bool, guess_type, from_str, from_env, cast_str, and
parameter type annotations where missing
- Table.py:
- __init__ (schema: Schema)
- __eq__ (rhs: Any)
- _column_data_type (name: str)
- _column_default (name: str)
- column_default (name: str)
- foreign_keys_to_parent_table (parent_table: Any)
- misc.py:
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- multi_regex_edit (spec: Any)
- dump_dict (*args: Any, **kwargs: Any)
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- dump (*args: Any, **kwargs: Any)
- MapAttr2Shape.py, ShuntingYard.py, Queries.py:
- Add parameter and return type annotations to fix disallow_incomplete_defs:
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- Queries.py: _run, _register, name property, __getitem__, keys, load, add, _add
- Add parameter and return type annotations:
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- auth/Auth.py: load, conf, _entity, projects
- auth/ldap/Auth.py: __init__, _create_entity
- Fix parameter type annotations:
- rows_check_not_null: keys: str | list[str], stat_key: str | None, caller: Any
- rows_dumps: lead: str | list[str] | None, tablefmt: str | None
- rows_dump: heading: str | None, lead: str | list[str] | None, tablefmt: str | None
- Table.py: column_default, add_row_location, add_child_row_location
- CompositeForeignKey.py: __table, parent_column, child_column
- TableIoHandler.py: _load, _store, load
- Query.py: _register, register, parent property
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- MapAttr2Shape.py, auth/ldap/Auth.py, Query.py:
- MapAttr2Shape.py: Add None check for id, add None check for graph
- auth/ldap/Auth.py: Add Any import, fix __init__ and _create_entity
- Query.py: Fix _add, run, parent signatures
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- Config.py: dump
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- ShellCmd.py: __init__
- auth/Auth.py: load, __init__
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- auth/ldap/Auth.py: Entity.__init__, Auth.__init__, _create_entity
- cast.py: guess_type
- DataBase.py: _create_session, _delete_session
- TableIoHandler.py: load
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
- ldap.py: Config.__get__, Config properties, Connection methods, inner callbacks
- misc.py: get_derived_classes, load_classes, load_class_names, load_object,
multi_regex_edit, dump_dict, dump
- multi_key_dict.py: items
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 22:34:10 +02:00
|
|
|
def conf(self) -> Config:
|
2025-02-14 14:29:30 +01:00
|
|
|
return self.__conf
|
|
|
|
|
|
2025-06-05 20:48:14 +02:00
|
|
|
@abc.abstractmethod
|
2026-06-10 13:28:35 +02:00
|
|
|
def _access(
|
2026-07-13 19:35:49 +02:00
|
|
|
self, what: str, access_type: Access | None, who: Entity | Group | None
|
2026-06-10 13:28:35 +02:00
|
|
|
) -> bool:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
def access(
|
|
|
|
|
self,
|
|
|
|
|
what: str,
|
2026-07-04 11:55:56 +02:00
|
|
|
access_type: Access | None = None,
|
2026-07-13 19:35:49 +02:00
|
|
|
who: Entity | Group | None = None
|
2026-06-10 13:28:35 +02:00
|
|
|
) -> bool:
|
2025-06-05 20:48:14 +02:00
|
|
|
return self._access(what, access_type, who)
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
2026-07-13 19:35:49 +02:00
|
|
|
def _current_entity(self) -> Entity:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2025-02-14 14:29:30 +01:00
|
|
|
@property
|
2026-07-13 19:35:49 +02:00
|
|
|
def current_entity(self) -> Entity:
|
|
|
|
|
return self._current_entity()
|
2025-02-14 14:29:30 +01:00
|
|
|
|
2025-06-05 20:48:14 +02:00
|
|
|
@abc.abstractmethod
|
mypy: Fix disallow_incomplete_defs fallout
Add parameter and return type annotations to untyped functions all
over the package:
- ldap.py: Add return types to Config properties (ldap_uri, bind_dn,
bind_pw, base_dn), Connection.__init__, add, delete, walk, find,
__oc_recurse_to_top, object_class_path, and inner callbacks
- cast.py: Add Any import, add return type annotations to
cast_str_to_bool, guess_type, from_str, from_env, cast_str, and
parameter type annotations where missing
- Table.py:
- __init__ (schema: Schema)
- __eq__ (rhs: Any)
- _column_data_type (name: str)
- _column_default (name: str)
- column_default (name: str)
- foreign_keys_to_parent_table (parent_table: Any)
- misc.py:
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- multi_regex_edit (spec: Any)
- dump_dict (*args: Any, **kwargs: Any)
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- dump (*args: Any, **kwargs: Any)
- MapAttr2Shape.py, ShuntingYard.py, Queries.py:
- Add parameter and return type annotations to fix disallow_incomplete_defs:
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- Queries.py: _run, _register, name property, __getitem__, keys, load, add, _add
- Add parameter and return type annotations:
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- auth/Auth.py: load, conf, _entity, projects
- auth/ldap/Auth.py: __init__, _create_entity
- Fix parameter type annotations:
- rows_check_not_null: keys: str | list[str], stat_key: str | None, caller: Any
- rows_dumps: lead: str | list[str] | None, tablefmt: str | None
- rows_dump: heading: str | None, lead: str | list[str] | None, tablefmt: str | None
- Table.py: column_default, add_row_location, add_child_row_location
- CompositeForeignKey.py: __table, parent_column, child_column
- TableIoHandler.py: _load, _store, load
- Query.py: _register, register, parent property
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- MapAttr2Shape.py, auth/ldap/Auth.py, Query.py:
- MapAttr2Shape.py: Add None check for id, add None check for graph
- auth/ldap/Auth.py: Add Any import, fix __init__ and _create_entity
- Query.py: Fix _add, run, parent signatures
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- Config.py: dump
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- ShellCmd.py: __init__
- auth/Auth.py: load, __init__
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- auth/ldap/Auth.py: Entity.__init__, Auth.__init__, _create_entity
- cast.py: guess_type
- DataBase.py: _create_session, _delete_session
- TableIoHandler.py: load
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
- ldap.py: Config.__get__, Config properties, Connection methods, inner callbacks
- misc.py: get_derived_classes, load_classes, load_class_names, load_object,
multi_regex_edit, dump_dict, dump
- multi_key_dict.py: items
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 22:34:10 +02:00
|
|
|
def _entity(self, name: str, kind: Kind) -> Entity:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def entity(self, name: str, kind: Kind) -> Entity:
|
|
|
|
|
return self._entity(name, kind)
|
2025-06-05 20:48:14 +02:00
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
2026-07-13 19:35:49 +02:00
|
|
|
def _entities(self, kind: Kind) -> Mapping[str, Entity]:
|
2026-07-04 11:55:56 +02:00
|
|
|
...
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def entities(self, kind: Kind) -> Mapping[str, Entity]:
|
|
|
|
|
return self._entities(kind)
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def _entity_by_email(self, email: str, kind: Kind) -> Entity:
|
|
|
|
|
if self.__base_entity_by_email is None:
|
|
|
|
|
ret: dict[str, Entity] = dict()
|
|
|
|
|
entities = self._entities(kind)
|
|
|
|
|
for entity in entities.values():
|
|
|
|
|
ret[entity.email] = entity
|
|
|
|
|
self.__base_entity_by_email = ret
|
|
|
|
|
return self.__base_entity_by_email[email]
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def entity_by_email(self, email: str, kind: Kind) -> Entity:
|
|
|
|
|
return self._entity_by_email(email, kind)
|
2025-06-05 20:48:14 +02:00
|
|
|
|
2026-07-13 19:35:49 +02:00
|
|
|
def user_by_email(self, email: str) -> Entity:
|
|
|
|
|
return self._entity_by_email(email, Kind.User)
|
|
|
|
|
|
|
|
|
|
# -- Convenience / legacy wrappers
|
2025-06-05 20:48:14 +02:00
|
|
|
|
mypy: Fix disallow_incomplete_defs fallout
Add parameter and return type annotations to untyped functions all
over the package:
- ldap.py: Add return types to Config properties (ldap_uri, bind_dn,
bind_pw, base_dn), Connection.__init__, add, delete, walk, find,
__oc_recurse_to_top, object_class_path, and inner callbacks
- cast.py: Add Any import, add return type annotations to
cast_str_to_bool, guess_type, from_str, from_env, cast_str, and
parameter type annotations where missing
- Table.py:
- __init__ (schema: Schema)
- __eq__ (rhs: Any)
- _column_data_type (name: str)
- _column_default (name: str)
- column_default (name: str)
- foreign_keys_to_parent_table (parent_table: Any)
- misc.py:
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- multi_regex_edit (spec: Any)
- dump_dict (*args: Any, **kwargs: Any)
- get_derived_classes (mod: Any, flt: Any)
- load_classes (flt: Any)
- load_class_names (remove_flt: bool)
- load_object (*args: Any, **kwargs: Any)
- dump (*args: Any, **kwargs: Any)
- MapAttr2Shape.py, ShuntingYard.py, Queries.py:
- Add parameter and return type annotations to fix disallow_incomplete_defs:
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- Queries.py: _run, _register, name property, __getitem__, keys, load, add, _add
- Add parameter and return type annotations:
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- auth/Auth.py: load, conf, _entity, projects
- auth/ldap/Auth.py: __init__, _create_entity
- Fix parameter type annotations:
- rows_check_not_null: keys: str | list[str], stat_key: str | None, caller: Any
- rows_dumps: lead: str | list[str] | None, tablefmt: str | None
- rows_dump: heading: str | None, lead: str | list[str] | None, tablefmt: str | None
- Table.py: column_default, add_row_location, add_child_row_location
- CompositeForeignKey.py: __table, parent_column, child_column
- TableIoHandler.py: _load, _store, load
- Query.py: _register, register, parent property
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- MapAttr2Shape.py, auth/ldap/Auth.py, Query.py:
- MapAttr2Shape.py: Add None check for id, add None check for graph
- auth/ldap/Auth.py: Add Any import, fix __init__ and _create_entity
- Query.py: Fix _add, run, parent signatures
- ArgsContainer.py: __setattr__, args, kwargs, dump, specified_args, add_argument
- Config.py: dump
- ShuntingYard.py: Op.__init__, tokenize, infix_to_postfix, eval_postfix, eval
- ShellCmd.py: __init__
- auth/Auth.py: load, __init__
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- auth/ldap/Auth.py: Entity.__init__, Auth.__init__, _create_entity
- cast.py: guess_type
- DataBase.py: _create_session, _delete_session
- TableIoHandler.py: load
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- rows.py: rows_duplicates, rows_check_not_null, rows_dumps, rows_dump
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
- ldap.py: Config.__get__, Config properties, Connection methods, inner callbacks
- misc.py: get_derived_classes, load_classes, load_class_names, load_object,
multi_regex_edit, dump_dict, dump
- multi_key_dict.py: items
- MapAttr2Shape.py: __keys, __attribs, __massage_node, __massage_nodes, __add
- auth/dummy/Auth.py: Entity.__init__, Auth.__init__
- Query.py: _run, _register, register, _add, run, parent/db properties
- QueryResult.py: pages, _cast
- Column.py: __eq__, foreign_key
- Schema.py: _access_defining_columns, access_defining_columns, table_by_model_name
- Table.py: __init__, __eq__, _column_data_type, _column_default, column_default,
__relationship_by_foreign_table, add_row_location, add_child_row_location
- utils.py: check_schema
- EventRouter.py: iter_peers
- Group.py: __init__
- SimpleEntity.py: __init__
- Ldap.py: Entity.__init__, Ldap.__init__, _create_entity
- Event.py: __init__
- Fuse.py: __init__
- Object.py: __init__
- SimpleObject.py: __init__, create
- EvRequest.py: __init__
- Msg.py: __init__
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 22:34:10 +02:00
|
|
|
def projects(self, name: str, flags: ProjectFlags) -> Sequence[str]:
|
2026-07-13 19:35:49 +02:00
|
|
|
log(
|
|
|
|
|
WARNING,
|
|
|
|
|
'Using Auth.projects() is deprecated. Use Entity.projects() instead!'
|
|
|
|
|
)
|
|
|
|
|
entity = self.entity(name, Kind.User)
|
|
|
|
|
return entity.projects(flags)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def users(self) -> Mapping[str, Entity]:
|
|
|
|
|
return self.entities(Kind.User)
|
|
|
|
|
|
|
|
|
|
def user(self, name: str) -> Entity:
|
|
|
|
|
return self.entity(name, Kind.User)
|