biometrics_tracker.model.exporters module
- class biometrics_tracker.model.exporters.CSVExporter(queue_mgr: Queues, person: Person, start_date: date, end_date: date, date_fmt: str, time_fmt: str, indexed_fields: dict[str, int], uom_handling: UOMHandlingType, export_dir_path: Path, completion_destination: Callable, include_header_row: bool, csv_dialect: Dialect = 'excel')
Bases:
ExporterBase
- close_csv_file()
Handle the close action. Closes the export file
- Returns
None
- column_action(data)
Handles the column action. Formats the value, and if specified, the u.o.m. If the u.o.m. is to be put in its own row, a tuple containing the formatted metric value and the u.o.m. is returned. Otherwise a single string is returned.
- Parameters
data (biometrics_tracker.model.datapoints.BloodPressure, Pulse, BloodGlucose, etc) – a instance of one of the metrics classes
- Returns
None
- create_csv_file()
Handle the open action. Creates a text file and, if specified, writes a header row to the CSV file
- Returns
None
- row_action()
Handle the row action. Write a csv file record
- Returns
None
- class biometrics_tracker.model.exporters.ExportSpec(id: str, export_type: ExportType, include_header_row: bool, uom_handling_type: UOMHandlingType, date_format: str, time_format: str, column_types: dict[int, str])
Bases:
object
Used to persist the entry values of the biometrics_tracker.gui.tk_gui.ExportFrame for reuse.
- class biometrics_tracker.model.exporters.ExportSpecsCollection
Bases:
object
Used to persist a number of instances of ExportSpec, keyed by the ExportSpec.id property
- class biometrics_tracker.model.exporters.ExportSpecsPickler(pickle_path: Path)
Bases:
object
Provides pickling and unpickling for an instance of ExportSpecsCollection
- retrieve() Optional[ExportSpecsCollection]
Unpickles and returns an instance of ExportSpecsCollection
- Returns
biometrics_tracker.model.exporters.ExportSpecsCollection
- save(specs: ExportSpecsCollection)
Pickles the provided ExportSpecsCollection instance
- Parameters
specs (biometrics_tracker.model.exporters.ExportSpecsCollection) – the ExportFrame enty values to be preserved for later use
- Returns
None
- class biometrics_tracker.model.exporters.ExportType(value)
Bases:
Enum
An enumeration.
- class biometrics_tracker.model.exporters.ExporterBase(export_type: ExportType, queue_mgr: Queues, person: Person, start_date: date, end_date: date, indexed_fields: dict[str, int], date_fmt: str, time_fmt: str, uom_handling: UOMHandlingType, export_dir_path: Path, file_name: str, completion_destination: Optional[Callable])
Bases:
Thread
A base class for classes that produce export files from the Biometrics Tracking database
- fmt_date(dt: date)
Formats a date using the format selected by the user
- Parameters
dt (datetime.date) – The date to be formated
- Returns
A formatted string date
- Return type
str
- fmt_time(tm: time)
Formats a time using the format selected by the user
- Parameters
tm (datetime.time) – The time to be formated
- Returns
A formatted string time
- Return type
str
- fmt_value(value: Union[int, Decimal, tuple[int, int]], uom: UOM) str
Formats a metric value, appending the u.o.m. if requested by the user
- Parameters
value (Union[int, Decimal, tuple[int, int]]) – a tuple of (systolic, diastolic) for blood pressure, a single numeric value for all others
uom (biometrics_tracker.model.uoms.UOM) – the UOM associated with the metrics
- Returns
a formatted string
- Return type
str
- produce_export(msg: DataPointRespMsg)
Produces the export file, using callbacks specified by subclasses to handle open, column, row and close actions :param msg: a response message containing a list of DataPoints :type msg: biometrics_tracker.ipc.messages.DataPointRespMsg :return: None
- run() None
This method in invoked when the thread is started. It sends a request to the persistence manager to retrieve the datapoints for the specified person
- Returns
None
- class biometrics_tracker.model.exporters.SQLiteExporter(queue_mgr: Queues, person: Person, start_date: date, end_date: date, date_fmt: str, time_fmt: str, indexed_fields: dict[str, int], uom_handling: UOMHandlingType, export_dir_path: Path, completion_destination: Callable)
Bases:
ExporterBase
Creates an SQLite databaes file and exports datapoints to it. The database consists of two tables: PEOPLE and EXPORT.
- close_sqlite_db()
Handles the close action. Closes the connection to the export database
- Returns
None
- column_action(data)
Handle the column action. Formats the value, and if specified, the u.o.m. If the u.o.m. is to be put in its own row, a tuple containing the formatted metric value and the u.o.m. is returned. Otherwise a single string is returned.
- Parameters
data (biometrics_tracker.model.datapoints.BloodPressure, Pulse, BloodGlucose, etc) – a instance of one of the metrics classes
- Returns
None
- create_sqlite_db()
- Handles the open action. Creates the database file, inserts a single row into the PEOPLE table and builds
an insert statement to be used to insert rows into the EXPORT table.
- Returns
None
- insert_data()
Handles the row action. Inserts a row into the EXPORT table
- Returns
None
- class biometrics_tracker.model.exporters.UOMHandlingType(value)
Bases:
Enum
An enumeration.