SP-Zugriffsweg explizit (access: api/snapshot, #133) und follow_up_at-Korrektur (dueWithTime/dueDay, #135)
Files changed: - CHANGES.md - INSTALL.md - VERSION - tools/CONTRACT.md - tools/chemenu/commands/doctor.py - tools/chemenu/commands/new_page.py - tools/chemenu/commands/review_cmd.py - tools/chemenu/review.py - tools/chemenu/tasks/__init__.py - tools/chemenu/tasks/config.py - tools/chemenu/tasks/protocol.py - tools/chemenu/tasks/superproductivity.py - tools/chemenu/tests/test_doctor.py - tools/chemenu/tests/test_new_page.py - tools/chemenu/tests/test_review.py - tools/chemenu/tests/test_superproductivity.py - tools/chemenu/tests/test_tasks_config.py
This commit is contained in:
1 parent
3c1d4cb028
commit
e07d1ca42a
17 files changed
+1112
-239
No files matched your search
@@ -24,11 +24,16 @@ from chemenu.tasks.protocol import TaskReader, TaskWriter
|
||||
|
||||
|
||||
def build_reader(cfg: TasksConfig) -> TaskReader:
|
||||
"""Dispatch on `cfg.provider` to a concrete `TaskReader`."""
|
||||
"""Dispatch on `cfg.provider` to a concrete `TaskReader`. For
|
||||
`superproductivity` the concrete class also depends on
|
||||
`access` (Gitea #133): `"api"` reads the live local REST API,
|
||||
`"snapshot"` reads the backup file - never both, never a fallback."""
|
||||
if cfg.provider == "superproductivity":
|
||||
from chemenu.tasks import superproductivity as sp
|
||||
|
||||
sp_cfg = sp.SuperProductivityConfig.from_dict(cfg.provider_config)
|
||||
if sp_cfg.access == sp.ACCESS_API:
|
||||
return sp.SuperProductivityApiReader(sp_cfg)
|
||||
return sp.SuperProductivityReader(sp_cfg)
|
||||
raise ValidationError(f"No reader is wired up for task provider {cfg.provider!r}.")
|
||||
|
||||
@@ -37,10 +42,23 @@ def build_writer(cfg: TasksConfig, reader: TaskReader) -> TaskWriter:
|
||||
"""Dispatch on `cfg.provider` to a concrete `TaskWriter`, over an
|
||||
already-built `reader` - a writer that needs to re-check the read path
|
||||
(e.g. `SuperProductivityWriter`'s own collision preflight) reads through
|
||||
the same object its caller does, rather than opening a second one."""
|
||||
the same object its caller does, rather than opening a second one.
|
||||
|
||||
For `superproductivity`, a writer exists only when `access: "api"`
|
||||
(Gitea #133): on `access: "snapshot"` the tracker is read-only from here
|
||||
by construction, so this raises `ValidationError` rather than returning a
|
||||
writer that could never do anything - the same posture as "no writer is
|
||||
wired up for this provider at all", just scoped to one access mode of
|
||||
one provider instead of the whole provider."""
|
||||
if cfg.provider == "superproductivity":
|
||||
from chemenu.tasks import superproductivity as sp
|
||||
|
||||
sp_cfg = sp.SuperProductivityConfig.from_dict(cfg.provider_config)
|
||||
if sp_cfg.access != sp.ACCESS_API:
|
||||
raise ValidationError(
|
||||
"superproductivity: the tracker is read-only from here (access: "
|
||||
f"'{sp_cfg.access}') - the write path only exists on an access: 'api' "
|
||||
"instance (Gitea #133)."
|
||||
)
|
||||
return sp.SuperProductivityWriter(sp_cfg, reader)
|
||||
raise ValidationError(f"No writer is wired up for task provider {cfg.provider!r}.")
|
||||
Reference in new issue
Block a user