summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-04-20 23:41:56 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-04-20 23:41:56 -0600
commit7ecd3c9501a16da6c1872ed7521f93df9a8da7f5 (patch)
treeb1a4108b138acb34cd58f40a9221d245476e2be6 /src
parentcbcf4f6f2c2264cff9e52ebb1cfd654a302d74f0 (diff)
mayor bugfix in the database writerv0.6.2
database was writing only one of the file info, effectively deleting all db
Diffstat (limited to 'src')
-rw-r--r--src/pyssg/database.py34
-rw-r--r--src/pyssg/pyssg.py3
2 files changed, 22 insertions, 15 deletions
diff --git a/src/pyssg/database.py b/src/pyssg/database.py
index c13df89..66c7087 100644
--- a/src/pyssg/database.py
+++ b/src/pyssg/database.py
@@ -1,6 +1,10 @@
import os
import sys
from logging import Logger, getLogger
+from configparser import ConfigParser
+from tabnanny import check
+
+from .utils import get_checksum
log: Logger = getLogger(__name__)
@@ -9,9 +13,11 @@ log: Logger = getLogger(__name__)
class Database:
__COLUMN_NUM: int = 4
- def __init__(self, db_path: str):
+ def __init__(self, db_path: str,
+ config: ConfigParser):
log.debug('initializing the page db on path "%s"', db_path)
self.db_path: str = db_path
+ self.config: ConfigParser = config
self.e: dict[str, tuple[float, float, list[str]]] = dict()
@@ -87,19 +93,19 @@ class Database:
def write(self) -> None:
log.debug('writing db')
- for k, v in self.e.items():
- log.debug('parsing row for page "%s"', k)
- t: str = None
- row: str = None
- if len(v[2]) == 0:
- t = '-'
- else:
- t = ','.join(v[2])
-
- row = f'{k} {v[0]} {v[1]} {t}'
-
- log.debug('writing row: "%s\\n"', row)
- with open(self.db_path, 'w') as file:
+ with open(self.db_path, 'w') as file:
+ for k, v in self.e.items():
+ log.debug('parsing row for page "%s"', k)
+ t: str = None
+ row: str = None
+ if len(v[2]) == 0:
+ t = '-'
+ else:
+ t = ','.join(v[2])
+
+ row = f'{k} {v[0]} {v[1]} {t}'
+
+ log.debug('writing row: "%s\\n"', row)
file.write(f'{row}\n')
diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py
index 931a55f..af7b166 100644
--- a/src/pyssg/pyssg.py
+++ b/src/pyssg/pyssg.py
@@ -76,7 +76,8 @@ def main() -> None:
if args['build']:
log.debug('building the html files')
- db: Database = Database(os.path.join(config.get('path', 'src'), '.files'))
+ db_path: str = os.path.join(config.get('path', 'src'), '.files')
+ db: Database = Database(db_path, config)
db.read()
builder: Builder = Builder(config, db)