mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
38 lines
923 B
Python
Executable File
Vendored
38 lines
923 B
Python
Executable File
Vendored
#!/usr/bin/env python3
|
|
import os
|
|
import json
|
|
from src.backend.lib.storage import Storage
|
|
from src.backend.lib.config import Config
|
|
|
|
|
|
def load_config():
|
|
"""Load program configuration."""
|
|
with open('config.json', "r") as file:
|
|
config = json.load(file)
|
|
file.close()
|
|
return config
|
|
|
|
|
|
def write_config(config):
|
|
"""Write program configuration."""
|
|
with open('config.json', "w") as file:
|
|
json.dump(config, file)
|
|
file.close()
|
|
|
|
|
|
def set_book_directory(config=load_config(), *args):
|
|
"""Set book directory."""
|
|
if config["BOOKPATH"] == "":
|
|
try:
|
|
config["BOOKPATH"] = args[0]
|
|
except IndexError:
|
|
config["BOOKPATH"] = input("Input Book Directory ")
|
|
|
|
|
|
config_file = load_config()
|
|
config = Config(os.path.split(os.path.realpath(__file__))[0])
|
|
set_book_directory(config_file)
|
|
write_config(config_file)
|
|
storage = Storage(config)
|
|
storage.create_tables()
|