summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)