Skip to content

dbed 0003

HarbingerOfFire edited this page Sep 18, 2024 · 3 revisions

FILE HANDLER COMPATIBILITY

STATUS ACCEPTED

EFFECTIVE DATE: 9/18/2024

*REFERENCES: #28 #30

Purpose

Python has a type of object refered to as ReadableBuffer, SupportsWrite, SupportsRead, etc. that allow the objects that can be modified to be modified by certain modules that require such attributes. The goal of this feature is to make the tables for BivittatusDB one such object that has those attrbiutes. To do this several new methods will need to be implemented:

  • read: Get all raw data from a table
  • readline: Get a specific row from table
  • readlines: Get a range of rows from a table
  • write: add rows to table
  • seek: change current row number for reading (supports 0, 1, 2)
  • tell: get current row number for reading
  • readable: return wether the data is able to be read
  • writable: return wether the table can be written to
  • seekable: return if the data can be seeked through
  • isatty: returns if table is attached to a terminal logger (see logger)
  • fileno: returns the file descriptor of the logger file (see logger)
  • flush: flush changes to disk (e.g. save changes)
  • truncate: shorten a table to specified number of rows
  • detach: disable file-methods

LOGGER

Part of this feature is the introduction of a logger file. Errors and extra info relating directly to a table can (by choice) be written to the terminal. To do this you can use table.log() which will start the logger. Anytime an error in the table is encountered, a trace will be written to the terminal. To tell if a logger has been started for a table, just call table.isatty(), which tells you if the table is attached to a terminal for logging.
The logger works by creating and reading a file over and over again and printing any new lines it finds. Because of this, the logger has a file descriptor which is used as the file descriptor of the table if you call table.fileno().

Original Author

Name Date
HarbingerOfFire 9/2/24

Editors

Name Date Reason