keeptabs#
Keep tabs on the subjects you care about (technology watch; in French, “veille”).
Describe what to follow as watch specifications, let a scheduled tick acquire
and match what is new, and ask “what’s new” whenever you like.
By watch id, with everything on its default (this is what the command line runs):
>>> from keeptabs import tools
>>> tools.tick()
>>> tools.whats_new('gen-ai', since='3d')
With parts of your own (stores, fetchers, a matcher, a summarizer, senders):
>>> from keeptabs import tick, whats_new, make_digest
Functions
|
Send a digest to each channel reference, such as |
|
Text that renders as itself, on one line, in Markdown and in HTML: no link, tag, mention, heading or emphasis of its own. |
|
GET a URL politely: identified, and conditional when validators are known. |
|
Score an item against a spec's keywords, subtopics and entities. |
|
Build a digest, store it, and deliver it (for real only when |
The stores of one watch, in memory: for tests and throwaway runs. |
|
|
A complete, checked copy of a watch specification. |
|
A digest as Markdown, with no model involved. |
|
The |
|
Watch specifications, keyed by watch id, stored as YAML files. |
|
Run everything that is due, once, and say what happened. |
|
The stores of one watch. |
|
The items acquired since |
Classes
|
What a fetcher needs from an HTTP exchange. |
Exceptions
Another tick holds the lock. |
|
A watch specification that cannot be used, with the reason and the fix. |
- exception keeptabs.AlreadyRunning[source]#
Bases:
RuntimeErrorAnother tick holds the lock.
- class keeptabs.Response(status, body=b'', headers=dict())[source]#
Bases:
objectWhat a fetcher needs from an HTTP exchange.
- exception keeptabs.SpecError[source]#
Bases:
ValueErrorA watch specification that cannot be used, with the reason and the fix.
- keeptabs.deliver(text, channels, *, title, dry_run=True, senders=None)[source]#
Send a digest to each channel reference, such as
email:me@example.org,github:owner/repo#12(a discussion) orslack:.Dry-run by default: a real send reaches people and cannot be unsent. One failing channel does not stop the others.
- Return type:
- keeptabs.escape_text(text)[source]#
Text that renders as itself, on one line, in Markdown and in HTML: no link, tag, mention, heading or emphasis of its own.
>>> print(escape_text('Sprout <!channel> [click](https://evil.example) & co')) Sprout <!channel> \[click\](https://evil.example) & co >>> print(escape_text('ping @someone about #12\n# A heading')) ping @someone about #12 # A heading
- Return type:
- keeptabs.http_get(url, *, etag=None, last_modified=None, timeout=30)[source]#
GET a URL politely: identified, and conditional when validators are known.
- Return type:
- keeptabs.keyword_matcher(item, spec, *, mall=None)[source]#
Score an item against a spec’s keywords, subtopics and entities.
>>> spec = {'keywords': ['diffusion'], 'exclude_keywords': ['crypto'], ... 'subtopics': [{'id': 'video', 'priority': 'high', 'keywords': ['text-to-video']}], ... 'entities': [{'id': 'sora', 'name': 'Sora', 'aliases': []}]} >>> m = keyword_matcher({'title': 'Sora: a text-to-video diffusion model', 'summary': ''}, spec) >>> m['score'], m['subtopics'], m['entities'] (7.0, ['video'], ['sora']) >>> keyword_matcher({'title': 'Diffusion of crypto', 'summary': ''}, spec)['score'] 0.0
- Return type:
- keeptabs.make_digest(spec, mall, *, since=None, now=None, summarizer=None, send=False, senders=None, mark_reported=None)[source]#
Build a digest, store it, and deliver it (for real only when
send).mark_reportedsays whether the items count as reported from now on, so the next digest leaves them out. It defaults tosend: a dry run changes nothing, and can be followed by the real send of the same digest. Items are never marked when a delivery failed, so a digest that did not arrive is sent again.- Return type:
- keeptabs.memory_mall()[source]#
The stores of one watch, in memory: for tests and throwaway runs.
>>> sorted(memory_mall()) == sorted(STORE_KINDS) True
- Return type:
- keeptabs.normalize_spec(spec, *, watch_id=None)[source]#
A complete, checked copy of a watch specification.
Only
id(ortitle) is required: a spec starts as a vague idea.>>> spec = normalize_spec({'title': 'Gen AI', 'keywords': ['diffusion'], 'entities': ['Sora']}) >>> spec['id'], spec['min_score'], spec['digest']['cadence'], spec['sources'] ('gen-ai', 1.0, '1w', []) >>> spec['entities'] [{'name': 'Sora', 'id': 'sora', 'kind': 'thing', 'aliases': []}]
- Return type:
- keeptabs.render_markdown(digest)[source]#
A digest as Markdown, with no model involved.
>>> print(render_markdown({'title': 'Gen AI', 'since': '2026-01-01T00:00:00+00:00', ... 'until': '2026-01-08T00:00:00+00:00', 'total_new': 1, 'shown': 1, 'sections': [ ... {'id': 'video', 'title': 'Video', 'items': [{'title': 'A model', 'url': 'https://example.com/a', ... 'summary': 'It generates.', 'published': '2026-01-05T00:00:00+00:00', 'source': 'blog'}]}], ... 'new_entities': [], 'active_entities': [], 'failing_sources': []})) # What's new: Gen AI 2026-01-01 to 2026-01-08. 1 new item. ## Video - [A model](https://example.com/a) (blog, 2026-01-05). It generates.
- Return type:
- keeptabs.scheduled_digest(*, summarizer=None, senders=None)[source]#
The
on_digest_duecallback forkeeptabs.engine.tick().A period with nothing new is skipped. Otherwise the digest is written to the
digestsstore, and:with
digest.auto_send: true, it is sent, and its items count as reported once every channel took it;with channels but no
auto_send, nothing is sent and nothing is marked: the items wait for the owner’sdigest --send;with no channel at all, the stored digest is the report.
- keeptabs.spec_store(rootdir=None)[source]#
Watch specifications, keyed by watch id, stored as YAML files.
- Return type:
- keeptabs.tick(watch_ids=None, *, rootdir=None, specs=None, malls=None, fetchers=None, http_get=None, matcher=None, on_digest_due=None, lock=None, now=None, force=False)[source]#
Run everything that is due, once, and say what happened.
specs: the store of watch specifications (default: local files underrootdir).malls: a function from a watch id to that watch’s stores (default: local files). Stores of your own come in a pair: give bothspecsandmalls.fetchers: source kind to fetcher, added to the defaults.http_get: the one door to the network.matcher:match(item, spec, *, mall), scoring an item against a spec.on_digest_due: called with(spec, mall, now)for each watch whose digest is due (default:keeptabs.digest.scheduled_digest());Falsefor no digest.lock: a context manager held for the run, orFalsefor none. The default is a local file lock, and none when the stores are your own.force: run every enabled, unblocked source whatever its schedule.
A watch or a source that fails is reported in
failuresand does not stop the rest.- Return type:
- keeptabs.watch_mall(watch_id, *, rootdir=None)[source]#
The stores of one watch.
>>> import tempfile >>> mall = watch_mall('demo', rootdir=tempfile.mkdtemp()) >>> sorted(mall) ['digests', 'dropped', 'entities', 'items', 'runs', 'state'] >>> mall['items']['abc'] = {'title': 'Ça marche'} >>> mall['items']['abc'], list(mall['items']) ({'title': 'Ça marche'}, ['abc'])
- Return type:
- keeptabs.whats_new(spec, mall, *, since=None, max_items=None, now=None)[source]#
The items acquired since
since, grouped by subtopic, best first.sinceis a time, or a duration ago ('3d'). It defaults to the time of the last digest, or to a week ago when there has been none. What the last digest already reported is not reported again.- Return type:
Modules
The operations of keeptabs, as plain functions: JSON-able arguments in, a JSON-ready dict out. |
|
Answering "what's new", writing it up, and delivering it. |
|
The scheduled run: work out what is due, acquire it, match it, store it. |
|
Acquiring raw items from each kind of source. |
|
Deciding whether an item belongs to a watch, and to which part of it. |
|
The watch specification: what one tracked area is, and how it is watched. |
|
Where specs and acquired data live, behind |
|
Small pure helpers: app directories, durations, timestamps, URL canonicalisation. |