Fixed project structure
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
.env
|
.env
|
||||||
.idea
|
.idea
|
||||||
|
__pycache__
|
||||||
+3
-3
@@ -3,23 +3,23 @@ import logging
|
|||||||
from os import path
|
from os import path
|
||||||
from meme_otron import img_factory as imgf
|
from meme_otron import img_factory as imgf
|
||||||
from meme_otron import meme_db
|
from meme_otron import meme_db
|
||||||
|
from meme_otron import utils
|
||||||
|
|
||||||
logging.basicConfig(format="[%(asctime)s][%(levelname)s][%(module)s] %(message)s", level=logging.DEBUG)
|
logging.basicConfig(format="[%(asctime)s][%(levelname)s][%(module)s] %(message)s", level=logging.DEBUG)
|
||||||
|
|
||||||
imgf.load_fonts()
|
imgf.load_fonts()
|
||||||
meme_db.load_memes()
|
meme_db.load_memes()
|
||||||
|
|
||||||
dst_dir = path.abspath("templates")
|
dst_dir = utils.relative_path(__file__, "templates")
|
||||||
|
|
||||||
for f in os.listdir(dst_dir):
|
for f in os.listdir(dst_dir):
|
||||||
if path.isfile(path.join(dst_dir, f)):
|
if path.isfile(path.join(dst_dir, f)):
|
||||||
os.unlink(path.join(dst_dir, f))
|
os.unlink(path.join(dst_dir, f))
|
||||||
|
|
||||||
|
|
||||||
for meme_id in meme_db.DATA:
|
for meme_id in meme_db.DATA:
|
||||||
meme = meme_db.get_meme(meme_id)
|
meme = meme_db.get_meme(meme_id)
|
||||||
if meme is not None:
|
if meme is not None:
|
||||||
img = imgf.make(meme.template, meme.texts, debug=True)
|
img = imgf.make(meme.template, meme.texts, debug=True)
|
||||||
|
if img is not None:
|
||||||
img.save(path.join(dst_dir, meme.template))
|
img.save(path.join(dst_dir, meme.template))
|
||||||
print(meme_id)
|
print(meme_id)
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import os
|
|||||||
import os.path as path
|
import os.path as path
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
DEFAULT_FONT = "arial"
|
DEFAULT_FONT = "arial"
|
||||||
DEFAULT_FONT_SIZE = 0.05
|
DEFAULT_FONT_SIZE = 0.05
|
||||||
|
|
||||||
FONT_DIR = "../fonts"
|
FONT_DIR = utils.relative_path(__file__, "..", "fonts")
|
||||||
TEMPLATES_DIR = "../templates"
|
TEMPLATES_DIR = utils.relative_path(__file__, "..", "templates")
|
||||||
|
|
||||||
FONTS = {}
|
FONTS = {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os.path as path
|
||||||
|
|
||||||
from .types import Pos, Text, Meme
|
from .types import Pos, Text, Meme
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
DATA_FILE = "../memes.json"
|
DATA_FILE = utils.relative_path(__file__, "..", "memes.json")
|
||||||
|
|
||||||
DATA = {}
|
DATA = {}
|
||||||
ALIASES = {}
|
ALIASES = {}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import re
|
import re
|
||||||
|
import os.path as path
|
||||||
|
|
||||||
|
|
||||||
|
def relative_path(file, *args):
|
||||||
|
return path.realpath(path.join(path.dirname(path.realpath(file)), *args))
|
||||||
|
|
||||||
|
|
||||||
def read_key_safe(d, k, default=None):
|
def read_key_safe(d, k, default=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user