move db_path default to load_config
This commit is contained in:
parent
d0965d437b
commit
9b60540d07
|
@ -43,7 +43,7 @@ class PostFetcher:
|
||||||
raise_for_status=True,
|
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._db.row_factory = aiosqlite.Row
|
||||||
self._ctx_stack = stack
|
self._ctx_stack = stack
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -8,7 +8,7 @@ def make_sentence(cfg):
|
||||||
def test_sentence_input(self, sentence):
|
def test_sentence_input(self, sentence):
|
||||||
return True # all sentences are valid <3
|
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
|
db.text_factory = str
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
if cfg['learn_from_cw']:
|
if cfg['learn_from_cw']:
|
||||||
|
|
|
@ -50,6 +50,7 @@ def load_config(cfg_path):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cfg['generation_mode'] = TextGenerationMode.__members__[cfg['generation_mode']]
|
cfg['generation_mode'] = TextGenerationMode.__members__[cfg['generation_mode']]
|
||||||
|
cfg.setdefault('db_path', 'posts.db')
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue