personality_questionnaire.core.recent_databases

Remembering which databases an operator has recently used.

A lab operator plausibly switches between a few SQLite files across sessions – per-study databases, or a shared-drive copy versus a local scratch copy – so the Setup tab’s database picker offers a short most-recently-used list alongside browsing. The list is a convenience, not a correctness requirement: a write failure here is logged and swallowed rather than blocking a database switch.

Attributes

MAX_ENTRIES

How many recent database URLs to keep.

Functions

recent_databases_path(→ pathlib.Path)

Return where the most-recently-used database list is stored.

load_recent(→ list[str])

Return remembered database URLs, most-recently-used first.

remember_database(→ list[str])

Move url to the front of the recent list, capped and de-duplicated.

Module Contents

personality_questionnaire.core.recent_databases.MAX_ENTRIES = 8

How many recent database URLs to keep.

personality_questionnaire.core.recent_databases.recent_databases_path() → pathlib.Path[source]

Return where the most-recently-used database list is stored.

Sits beside the default database file, under the same $PQ_HOME (or ~/.personality_questionnaire) directory used elsewhere in this package.

Returns:

The path to the MRU JSON file.

personality_questionnaire.core.recent_databases.load_recent(path: pathlib.Path | None = None) → list[str][source]

Return remembered database URLs, most-recently-used first.

Parameters:

path – The MRU file to read. Defaults to recent_databases_path().

Returns:

The remembered URLs, or an empty list if the file is missing, unreadable, or not valid JSON – a corrupt MRU file is a non-event, not an error.

personality_questionnaire.core.recent_databases.remember_database(url: str, path: pathlib.Path | None = None) → list[str][source]

Move url to the front of the recent list, capped and de-duplicated.

Parameters:
Returns:

The updated list, most-recently-used first.