naturtag.storage.app_state module¶
- class naturtag.storage.app_state.AppState(history=NOTHING, starred=NOTHING, observed=NOTHING, setup_complete=False, last_obs_check=None, last_version='N/A', window_size=(1500, 1024))¶
Bases:
object
Container for persistent application state info. This includes values that don’t need to be human-readable/editable, so they are persisted in SQLite instead of
settings.yml
.- check_version_change()¶
Check if the app version has changed since the last run
-
db_path:
Path
= None¶
- property display_ids: set[int]¶
Return top history, frequent, observed, and starred taxa combined. Returns only unique IDs, since a given taxon may appear in more than one list.
-
frequent:
Counter
[int
] = None¶
- frequent_idx(taxon_id)¶
Return the position of a taxon in the frequent list, if it’s in the top
MAX_DISPLAY_HISTORY
taxa.- Return type:
Optional
[int
]
-
history:
list
[int
]¶
-
last_obs_check:
Optional
[datetime
]¶
-
last_version:
str
¶
-
observed:
dict
[int
,int
]¶
- classmethod read(db_path=PosixPath('/home/docs/.local/share/Naturtag/naturtag.db'))¶
Read app state from SQLite database, or return a new instance if no state is found
- Return type:
- set_obs_checkpoint()¶
-
setup_complete:
bool
¶
-
starred:
list
[int
]¶
- property top_frequent: list[int]¶
Get the most frequently viewed taxa
- property top_history: list[int]¶
Get the most recently viewed unique taxa
- property top_observed: list[int]¶
Get the most commonly observed taxa
- update_history(taxon_id)¶
Update history and frequent with a new or existing taxon ID
- update_observed(taxon_counts)¶
- view_count(taxon_id)¶
Return the number of times this taxon has been viewed
- Return type:
int
-
window_size:
tuple
[int
,int
]¶
- write()¶
Write app state to SQLite database. Table will be created if it doesn’t exist.