unused import cleanup

This commit is contained in:
Hayden 2021-01-12 13:39:00 -09:00
commit 77f66c43f3
2 changed files with 7 additions and 9 deletions

View file

@ -1,18 +1,16 @@
import json import json
import shutil import shutil
import zipfile
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from jinja2 import Template from jinja2 import Template
from services.meal_services import MealPlan
from services.recipe_services import Recipe from services.recipe_services import Recipe
from services.settings_services import SiteSettings, SiteTheme from services.settings_services import SiteSettings, SiteTheme
from settings import BACKUP_DIR, IMG_DIR, TEMP_DIR, TEMPLATE_DIR from settings import BACKUP_DIR, IMG_DIR, TEMP_DIR, TEMPLATE_DIR
from utils.logger import logger from utils.logger import logger
class DatabaseExport: class ExportDatabase:
def __init__(self, tag=None, templates=None) -> None: def __init__(self, tag=None, templates=None) -> None:
if tag: if tag:
export_tag = tag + "_" + datetime.now().strftime("%Y-%b-%d") export_tag = tag + "_" + datetime.now().strftime("%Y-%b-%d")
@ -55,7 +53,7 @@ class DatabaseExport:
filename = recipe.get("slug") + ".json" filename = recipe.get("slug") + ".json"
file_path = self.recipe_dir.joinpath(filename) file_path = self.recipe_dir.joinpath(filename)
DatabaseExport._write_json_file(recipe, file_path) ExportDatabase._write_json_file(recipe, file_path)
if self.templates: if self.templates:
self._export_template(recipe) self._export_template(recipe)
@ -81,7 +79,7 @@ class DatabaseExport:
def export_settings(self): def export_settings(self):
all_settings = SiteSettings.get_site_settings() all_settings = SiteSettings.get_site_settings()
out_file = self.settings_dir.joinpath("settings.json") out_file = self.settings_dir.joinpath("settings.json")
DatabaseExport._write_json_file(all_settings.dict(), out_file) ExportDatabase._write_json_file(all_settings.dict(), out_file)
def export_themes(self): def export_themes(self):
all_themes = SiteTheme.get_all() all_themes = SiteTheme.get_all()
@ -89,7 +87,7 @@ class DatabaseExport:
if all_themes: if all_themes:
all_themes = [x.dict() for x in all_themes] all_themes = [x.dict() for x in all_themes]
out_file = self.themes_dir.joinpath("themes.json") out_file = self.themes_dir.joinpath("themes.json")
DatabaseExport._write_json_file(all_themes, out_file) ExportDatabase._write_json_file(all_themes, out_file)
# def export_meals(self): #! Problem Parseing Datetime Objects... May come back to this # def export_meals(self): #! Problem Parseing Datetime Objects... May come back to this
# meal_plans = MealPlan.get_all() # meal_plans = MealPlan.get_all()
@ -117,7 +115,7 @@ class DatabaseExport:
def backup_all(tag=None, templates=None): def backup_all(tag=None, templates=None):
db_export = DatabaseExport(tag=tag, templates=templates) db_export = ExportDatabase(tag=tag, templates=templates)
db_export.export_recipes() db_export.export_recipes()
db_export.export_images() db_export.export_images()
@ -137,4 +135,4 @@ def auto_backup_job():
templates.append(template) templates.append(template)
backup_all(tag="Auto", templates=templates) backup_all(tag="Auto", templates=templates)
logger.info("Auto Backup Called") logger.info("Auto Backup Called")

View file

@ -5,7 +5,7 @@ from pathlib import Path
from typing import List from typing import List
from services.recipe_services import Recipe from services.recipe_services import Recipe
from settings import BACKUP_DIR, IMG_DIR, TEMP_DIR, TEMPLATE_DIR from settings import BACKUP_DIR, IMG_DIR, TEMP_DIR
from utils.logger import logger from utils.logger import logger