Add a test command to build html without generating media files
This commit is contained in:
parent
def75d1fa5
commit
0854f36c62
@ -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,20 +121,21 @@ class Video(object):
|
|||||||
CACHE.cache_picture(source, target, options)
|
CACHE.cache_picture(source, target, options)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
|
if not DEFAULTS['test']:
|
||||||
options = self.options.copy()
|
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
|
||||||
self.ffmpeg(source, target, options)
|
options = self.options.copy()
|
||||||
|
self.ffmpeg(source, target, options)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
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.update({"resize": gm_geometry})
|
||||||
|
|
||||||
options = self.options.copy()
|
self.ffmpeg(source, target, options)
|
||||||
options.update({"resize": gm_geometry})
|
|
||||||
|
|
||||||
self.ffmpeg(source, target, options)
|
|
||||||
|
|
||||||
return thumbnail_name
|
return thumbnail_name
|
||||||
|
|
||||||
@ -181,9 +184,10 @@ class Audio(object):
|
|||||||
CACHE.cache_picture(source, target, options)
|
CACHE.cache_picture(source, target, options)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
|
if not DEFAULTS['test']:
|
||||||
options = self.options.copy()
|
source, target = self.base_dir.joinpath(self.name), self.target_dir.joinpath(self.name)
|
||||||
self.ffmpeg(source, target, options)
|
options = self.options.copy()
|
||||||
|
self.ffmpeg(source, target, options)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -220,14 +224,14 @@ 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)
|
||||||
|
warning("Generation", source)
|
||||||
|
|
||||||
command = "gm convert '{source}' {auto-orient} {strip} {progressive} {quality} {resize} '{target}'".format(**gm_switches)
|
print(command)
|
||||||
warning("Generation", source)
|
error(os.system(command) == 0, "gm command failed")
|
||||||
|
|
||||||
print(command)
|
CACHE.cache_picture(source, target, options)
|
||||||
error(os.system(command) == 0, "gm command failed")
|
|
||||||
|
|
||||||
CACHE.cache_picture(source, target, options)
|
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
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)
|
||||||
@ -236,29 +240,29 @@ 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"]:
|
||||||
|
shutil.copyfile(source, target)
|
||||||
if not options["auto-orient"] and not options["strip"]:
|
print(("%s%s%s" % (source, "->", target)))
|
||||||
shutil.copyfile(source, target)
|
else:
|
||||||
print(("%s%s%s" % (source, "->", target)))
|
# Do not consider quality settings here, since we aim to copy the input image
|
||||||
else:
|
# better to preserve input encoding setting
|
||||||
# Do not consider quality settings here, since we aim to copy the input image
|
del options["quality"]
|
||||||
# better to preserve input encoding setting
|
self.gm(source, target, options)
|
||||||
del options["quality"]
|
|
||||||
self.gm(source, target, options)
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
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.update({"resize": gm_geometry})
|
||||||
|
|
||||||
options = self.options.copy()
|
self.gm(source, target, options)
|
||||||
options.update({"resize": gm_geometry})
|
|
||||||
|
|
||||||
self.gm(source, target, options)
|
|
||||||
|
|
||||||
return thumbnail_name
|
return thumbnail_name
|
||||||
|
|
||||||
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user