do not clear output by default
This commit is contained in:
parent
4ceb1ef9e3
commit
fdd25f3de6
@ -15,13 +15,14 @@ def config_file() -> Optional[str]:
|
|||||||
|
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
db = "spip"
|
db: str = "spip"
|
||||||
db_host = "localhost"
|
db_host: str = "localhost"
|
||||||
db_user = "spip"
|
db_user: str = "spip"
|
||||||
db_pass = "password"
|
db_pass: str = "password"
|
||||||
output_dir = "output"
|
output_dir: str = "output"
|
||||||
default_export_max = 1000
|
default_export_max: int = 1000
|
||||||
data_dir = "data"
|
data_dir: str = "data"
|
||||||
|
clear_output: bool = False
|
||||||
|
|
||||||
def __init__(self, config_file: Optional[str] = None) -> None:
|
def __init__(self, config_file: Optional[str] = None) -> None:
|
||||||
if config_file is not None:
|
if config_file is not None:
|
||||||
@ -39,6 +40,8 @@ class Configuration:
|
|||||||
self.default_export_max = config["default_export_max"]
|
self.default_export_max = config["default_export_max"]
|
||||||
if "data_dir" in config:
|
if "data_dir" in config:
|
||||||
self.data_dir = config["data_dir"]
|
self.data_dir = config["data_dir"]
|
||||||
|
if "clear_output" in config:
|
||||||
|
self.clear_output = config["clear_output"]
|
||||||
|
|
||||||
|
|
||||||
config = Configuration(config_file())
|
config = Configuration(config_file())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!python
|
#!python
|
||||||
# pyright: strict
|
# pyright: strict
|
||||||
from os import makedirs, mkdir
|
from os import makedirs
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from shutil import copyfile, rmtree
|
from shutil import copyfile, rmtree
|
||||||
from sys import argv
|
from sys import argv
|
||||||
@ -58,9 +58,10 @@ if __name__ == "__main__": # Only if script is directly executed
|
|||||||
else:
|
else:
|
||||||
toexport = config.default_export_max
|
toexport = config.default_export_max
|
||||||
|
|
||||||
# Clear the output dir & create a new
|
if config.clear_output:
|
||||||
rmtree(config.output_dir, True)
|
# Clear the output dir & create a new
|
||||||
mkdir(config.output_dir)
|
rmtree(config.output_dir, True)
|
||||||
|
makedirs(config.output_dir, exist_ok=True)
|
||||||
|
|
||||||
# Articles that contains unknown chars
|
# Articles that contains unknown chars
|
||||||
unknown_chars_articles: list[Article] = []
|
unknown_chars_articles: list[Article] = []
|
||||||
|
Loading…
Reference in New Issue
Block a user