Add a test command to build html without generating media files

This commit is contained in:
Thomas Nonglaton 2017-10-18 13:58:17 +02:00
parent def75d1fa5
commit 0854f36c62

View File

@ -3,6 +3,7 @@
"""Prosopopee. Static site generator for your story. """Prosopopee. Static site generator for your story.
Usage: Usage:
prosopopee.py prosopopee.py
prosopopee.py test
prosopopee.py preview prosopopee.py preview
prosopopee.py deploy prosopopee.py deploy
prosopopee.py (-h | --help) prosopopee.py (-h | --help)
@ -33,6 +34,7 @@ DEFAULTS = {
"share": False, "share": False,
"settings": {}, "settings": {},
"show_date": True, "show_date": True,
"test": False,
} }
SETTINGS = { SETTINGS = {
@ -119,6 +121,7 @@ class Video(object):
CACHE.cache_picture(source, target, options) CACHE.cache_picture(source, target, options)
def copy(self): def copy(self):
if not DEFAULTS['test']:
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name) source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
options = self.options.copy() options = self.options.copy()
self.ffmpeg(source, target, options) self.ffmpeg(source, target, options)
@ -126,7 +129,7 @@ class Video(object):
def generate_thumbnail(self, gm_geometry): def generate_thumbnail(self, gm_geometry):
thumbnail_name = ".".join(self.name.split(".")[:-1]) + "-%s.jpg" % gm_geometry thumbnail_name = ".".join(self.name.split(".")[:-1]) + "-%s.jpg" % gm_geometry
if not DEFAULTS['test']:
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(thumbnail_name) source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(thumbnail_name)
options = self.options.copy() options = self.options.copy()
@ -181,6 +184,7 @@ class Audio(object):
CACHE.cache_picture(source, target, options) CACHE.cache_picture(source, target, options)
def copy(self): def copy(self):
if not DEFAULTS['test']:
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name) source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
options = self.options.copy() options = self.options.copy()
self.ffmpeg(source, target, options) self.ffmpeg(source, target, options)
@ -220,7 +224,7 @@ class Image(object):
"resize": "-resize %s" % options["resize"] if options.get("resize", None) is not None else "", "resize": "-resize %s" % options["resize"] if options.get("resize", None) is not None else "",
"progressive": "-interlace Line" if options.get("progressive", None) is True else "" "progressive": "-interlace Line" if options.get("progressive", None) is True else ""
} }
if not DEFAULTS['test']:
command = "gm convert '{source}' {auto-orient} {strip} {progressive} {quality} {resize} '{target}'".format(**gm_switches) command = "gm convert '{source}' {auto-orient} {strip} {progressive} {quality} {resize} '{target}'".format(**gm_switches)
warning("Generation", source) warning("Generation", source)
@ -236,7 +240,7 @@ class Image(object):
# if os.path.exists(target) and os.path.getsize(source) == os.path.getsize(target): # if os.path.exists(target) and os.path.getsize(source) == os.path.getsize(target):
# print "Skipped %s since the file hasn't been modified based on file size" % source # print "Skipped %s since the file hasn't been modified based on file size" % source
# return "" # return ""
if not DEFAULTS['test']:
options = self.options.copy() options = self.options.copy()
if not options["auto-orient"] and not options["strip"]: if not options["auto-orient"] and not options["strip"]:
@ -252,7 +256,7 @@ class Image(object):
def generate_thumbnail(self, gm_geometry): def generate_thumbnail(self, gm_geometry):
thumbnail_name = ".".join(self.name.split(".")[:-1]) + "-" + gm_geometry + "." + self.name.split(".")[-1] thumbnail_name = ".".join(self.name.split(".")[:-1]) + "-" + gm_geometry + "." + self.name.split(".")[-1]
if not DEFAULTS['test']:
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(thumbnail_name) source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(thumbnail_name)
options = self.options.copy() options = self.options.copy()
@ -565,6 +569,8 @@ def main():
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 "
"DIRECTORY in your current working directory), you don't have any gallery?") "DIRECTORY in your current working directory), you don't have any gallery?")
if arguments['test']:
DEFAULTS['test'] = True
if arguments['preview']: if arguments['preview']:
error(Path("build").exists(), "Please build the website before launch preview") error(Path("build").exists(), "Please build the website before launch preview")