From 9b60540d070731934924d57fd380c58a6ddc03e4 Mon Sep 17 00:00:00 2001 From: io Date: Mon, 26 Jul 2021 06:47:43 +0000 Subject: [PATCH] move db_path default to load_config --- fetch_posts.py | 2 +- generators/markov.py | 2 +- third_party/utils.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fetch_posts.py b/fetch_posts.py index ba41d71..29c0391 100755 --- a/fetch_posts.py +++ b/fetch_posts.py @@ -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 diff --git a/generators/markov.py b/generators/markov.py index ae7e76f..bea9268 100644 --- a/generators/markov.py +++ b/generators/markov.py @@ -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']: diff --git a/third_party/utils.py b/third_party/utils.py index f36afb3..1eac5f3 100644 --- a/third_party/utils.py +++ b/third_party/utils.py @@ -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