diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-12-08 03:18:31 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-12-08 03:18:31 -0600 |
commit | 35ff363e779149b6364901a53dd1eefe89ca5ddb (patch) | |
tree | 579302f30c3796d7c32885c63f2e0e8de5813cb4 /src/pyssg/database.py | |
parent | 40d23848d816816b3db3e7296e8a28f964b53786 (diff) |
refactor code, small bug fixing and changes
Diffstat (limited to 'src/pyssg/database.py')
-rw-r--r-- | src/pyssg/database.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/pyssg/database.py b/src/pyssg/database.py index d4b6a86..d9c6467 100644 --- a/src/pyssg/database.py +++ b/src/pyssg/database.py @@ -21,8 +21,10 @@ class Database: # updates the tags for a specific entry (file) # file_name only contains the entry name (not an absolute path) + # TODO: make the function return true/false if updated def update_tags(self, file_name: str, new_tags: list[str]) -> None: + # technically, I should ensure this function can only run if self.e is populated if file_name in self.e: log.debug('updating tags for entry "%s"', file_name) log.debug('entry "%s" old content: %s', @@ -103,7 +105,6 @@ class Database: if not os.path.isfile(self.db_path): log.error('"%s" is not a file"', self.db_path) sys.exit(1) - return True def _get_csv_rows(self) -> list[list[str]]: @@ -112,7 +113,6 @@ class Database: csv_reader = csv.reader(f, delimiter=self.__COLUMN_DELIMITER) rows = list(csv_reader) log.debug('db contains %d rows', len(rows)) - return rows def read(self) -> None: @@ -127,12 +127,10 @@ class Database: i: int = it + 1 col_num: int = len(row) log.debug('row %d content: "%s"', i, row) - if col_num != self.__COLUMN_NUM: log.critical('row %d doesn\'t contain %s columns, contains %d' ' columns: "%s"', i, self.__COLUMN_NUM, col_num, row) sys.exit(1) - entry: DatabaseEntry = DatabaseEntry(row) self.e[entry.fname] = entry |