updated magcms / ppee for newer python infrastructure
This commit is contained in:
parent
dbaf4047b4
commit
bfe35a1c5b
@ -296,7 +296,10 @@ def get_settings():
|
|||||||
"settings.yaml in the current working directory")
|
"settings.yaml in the current working directory")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
settings = yaml.safe_load(open("settings.yaml", "r"))
|
# Deprecated:
|
||||||
|
# settings = yaml.safe_load(open("settings.yaml", "r"))
|
||||||
|
yamli = yaml.YAML(typ='safe', pure=True)
|
||||||
|
settings = yamli.load(open("settings.yaml", "r"))
|
||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
if hasattr(exc, 'problem_mark'):
|
if hasattr(exc, 'problem_mark'):
|
||||||
mark = exc.problem_mark
|
mark = exc.problem_mark
|
||||||
@ -352,7 +355,9 @@ def get_settings():
|
|||||||
def get_gallery_templates(theme, gallery_path="", parent_templates=None):
|
def get_gallery_templates(theme, gallery_path="", parent_templates=None):
|
||||||
theme_path = Path(__file__).parent.joinpath("themes", theme).exists()
|
theme_path = Path(__file__).parent.joinpath("themes", theme).exists()
|
||||||
|
|
||||||
available_themes = theme, "', '".join(Path(__file__).parent.joinpath("themes").listdir())
|
# available_themes = theme, "', '".join(Path(__file__).parent.joinpath("themes").listdir())
|
||||||
|
themesdir = "".join(Path(__file__).parent.joinpath("themes"))
|
||||||
|
available_themes = theme, "', '".join(os.listdir(themesdir))
|
||||||
|
|
||||||
error(theme_path, "'%s' is not an existing theme, available themes are '%s'" % available_themes)
|
error(theme_path, "'%s' is not an existing theme, available themes are '%s'" % available_themes)
|
||||||
|
|
||||||
@ -387,7 +392,10 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p
|
|||||||
gallery_path = gallery_name
|
gallery_path = gallery_name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gallery_settings = yaml.safe_load(open(Path(".").joinpath(gallery_path, "settings.yaml").abspath(), "r"))
|
# DEPRECATED:
|
||||||
|
# gallery_settings = yaml.safe_load(open(Path(".").joinpath(gallery_path, "settings.yaml").abspath(), "r"))
|
||||||
|
yamli = yaml.YAML(typ='safe', pure=True)
|
||||||
|
gallery_settings = yamli.load(open(os.path.abspath(Path(".").joinpath(gallery_path, "settings.yaml")), "r"))
|
||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
if hasattr(exc, 'problem_mark'):
|
if hasattr(exc, 'problem_mark'):
|
||||||
mark = exc.problem_mark
|
mark = exc.problem_mark
|
||||||
@ -395,14 +403,14 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p
|
|||||||
else:
|
else:
|
||||||
error(False, "There are something wrong in %s/settings.yaml" % (gallery_path))
|
error(False, "There are something wrong in %s/settings.yaml" % (gallery_path))
|
||||||
|
|
||||||
error(isinstance(gallery_settings, dict), "Your %s should be a dict" % gallery_name.joinpath("settings.yaml"))
|
error(isinstance(gallery_settings, dict), "Your %s should be a dict" % os.path.join(gallery_name, "settings.yaml"))
|
||||||
error(gallery_settings.get("title"), "You should specify a title in %s" % gallery_name.joinpath("settings.yaml"))
|
error(gallery_settings.get("title"), "You should specify a title in %s" % os.path.join(gallery_name, "settings.yaml"))
|
||||||
|
|
||||||
gallery_cover = {}
|
gallery_cover = {}
|
||||||
|
|
||||||
sub_galleries = [x for x in Path(".").joinpath(gallery_path).listdir() if x.joinpath("settings.yaml").exists()]
|
sub_galleries = [x for x in os.listdir(os.path.join(Path("."), gallery_path)) if os.path.exists(os.path.join(x, "settings.yaml"))]
|
||||||
|
|
||||||
Path("build").joinpath(gallery_path).makedirs_p()
|
os.path.join(Path("build"), gallery_path).makedirs_p()
|
||||||
|
|
||||||
if not gallery_settings.get("public", True):
|
if not gallery_settings.get("public", True):
|
||||||
build_gallery(settings, gallery_settings, gallery_path, parent_templates)
|
build_gallery(settings, gallery_settings, gallery_path, parent_templates)
|
||||||
@ -414,7 +422,7 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
error(gallery_settings.get("sections") is not False,
|
error(gallery_settings.get("sections") is not False,
|
||||||
"The gallery in %s can't have both sections and subgalleries" % gallery_name.joinpath("settings.yaml"))
|
"The gallery in %s can't have both sections and subgalleries" % os.path.join(gallery_name, "settings.yaml"))
|
||||||
|
|
||||||
# Sub galleries found, create index with them instead of a gallery
|
# Sub galleries found, create index with them instead of a gallery
|
||||||
theme = gallery_settings.get("theme", settings.get("theme", "exposure"))
|
theme = gallery_settings.get("theme", settings.get("theme", "exposure"))
|
||||||
@ -443,18 +451,18 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p
|
|||||||
|
|
||||||
def create_cover(gallery_name, gallery_settings, gallery_path):
|
def create_cover(gallery_name, gallery_settings, gallery_path):
|
||||||
error(gallery_settings.get("title"), "Your gallery describe in %s need to have a "
|
error(gallery_settings.get("title"), "Your gallery describe in %s need to have a "
|
||||||
"title" % gallery_name.joinpath("settings.yaml"))
|
"title" % os.path.join(gallery_name, "settings.yaml"))
|
||||||
|
|
||||||
error(gallery_settings.get("cover"), "You should specify a path to a cover picture "
|
error(gallery_settings.get("cover"), "You should specify a path to a cover picture "
|
||||||
"in %s" % gallery_name.joinpath("settings.yaml"))
|
"in %s" % os.path.join(gallery_name, "settings.yaml"))
|
||||||
|
|
||||||
if isinstance(gallery_settings["cover"], dict):
|
if isinstance(gallery_settings["cover"], dict):
|
||||||
cover_image_path = gallery_path.joinpath(gallery_settings["cover"]["name"])
|
cover_image_path = Path(gallery_path).joinpath(gallery_settings["cover"]["name"])
|
||||||
cover_image_url = gallery_name.joinpath(gallery_settings["cover"]["name"])
|
cover_image_url = Path(gallery_name).joinpath(gallery_settings["cover"]["name"])
|
||||||
cover_image_type = gallery_settings["cover"]["type"]
|
cover_image_type = gallery_settings["cover"]["type"]
|
||||||
else:
|
else:
|
||||||
cover_image_path = gallery_path.joinpath(gallery_settings["cover"])
|
cover_image_path = Path(gallery_path).joinpath(gallery_settings["cover"])
|
||||||
cover_image_url = gallery_name.joinpath(gallery_settings["cover"])
|
cover_image_url = Path(gallery_name).joinpath(gallery_settings["cover"])
|
||||||
cover_image_type = "image"
|
cover_image_type = "image"
|
||||||
|
|
||||||
error(cover_image_path.exists(), "File for %s cover image doesn't exist at "
|
error(cover_image_path.exists(), "File for %s cover image doesn't exist at "
|
||||||
@ -625,7 +633,7 @@ def main():
|
|||||||
|
|
||||||
front_page_galleries_cover = []
|
front_page_galleries_cover = []
|
||||||
|
|
||||||
galleries_dirs = [x for x in Path(".").listdir() if x.joinpath("settings.yaml").exists()]
|
galleries_dirs = [x for x in os.listdir(Path(".")) if os.path.isfile(os.path.join(x, "settings.yaml"))]
|
||||||
|
|
||||||
error(galleries_dirs, "I can't find at least one directory with a settings.yaml in the current working "
|
error(galleries_dirs, "I can't find at least one directory with a settings.yaml in the current working "
|
||||||
"directory (NOT the settings.yaml in your current directory, but one INSIDE A "
|
"directory (NOT the settings.yaml in your current directory, but one INSIDE A "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user