move db_path default to load_config

This commit is contained in:
io 2021-07-26 06:47:43 +00:00
parent d0965d437b
commit 9b60540d07
3 changed files with 3 additions and 2 deletions

View file

@ -43,7 +43,7 @@ class PostFetcher:
raise_for_status=True,
),
)
self._db = await stack.enter_async_context(aiosqlite.connect(self.config.get('db_path', 'posts.db')))
self._db = await stack.enter_async_context(aiosqlite.connect(self.config['db_path']))
self._db.row_factory = aiosqlite.Row
self._ctx_stack = stack
return self

View file

@ -8,7 +8,7 @@ def make_sentence(cfg):
def test_sentence_input(self, sentence):
return True # all sentences are valid <3
db = sqlite3.connect(cfg.get("db_path", "posts.db"))
db = sqlite3.connect(cfg["db_path"])
db.text_factory = str
c = db.cursor()
if cfg['learn_from_cw']:

View file

@ -50,6 +50,7 @@ def load_config(cfg_path):
sys.exit(1)
cfg['generation_mode'] = TextGenerationMode.__members__[cfg['generation_mode']]
cfg.setdefault('db_path', 'posts.db')
return cfg