[enh] put default gm settings in a global dict, can be overridden in root settings.yaml
This commit is contained in:
parent
c23612e87b
commit
a2ae29b5c7
@ -16,6 +16,11 @@ page_template = templates.get_template("page.html")
|
|||||||
DEFAULT_GM_QUALITY = 75
|
DEFAULT_GM_QUALITY = 75
|
||||||
DEFAULT_GM_AUTOORIENT = False
|
DEFAULT_GM_AUTOORIENT = False
|
||||||
|
|
||||||
|
gm_settings = {
|
||||||
|
"quality" : 75,
|
||||||
|
"auto-orient" : True
|
||||||
|
}
|
||||||
|
|
||||||
CACHE_VERSION = 1
|
CACHE_VERSION = 1
|
||||||
|
|
||||||
|
|
||||||
@ -69,13 +74,8 @@ class Image(object):
|
|||||||
# assuming string
|
# assuming string
|
||||||
if not isinstance(options, dict):
|
if not isinstance(options, dict):
|
||||||
options = {"name": options}
|
options = {"name": options}
|
||||||
|
|
||||||
if not options.has_key("quality"):
|
|
||||||
options["quality"] = DEFAULT_GM_QUALITY
|
|
||||||
if not options.has_key("autoorient"):
|
|
||||||
options["autoorient"] = DEFAULT_GM_AUTOORIENT
|
|
||||||
|
|
||||||
self.options = options.copy() # used for caching, if it's modified -> regenerate
|
self.options = options.copy() # used for caching, if it's modified -> regenerate
|
||||||
|
self.options.update(gm_settings)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -87,7 +87,7 @@ class Image(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def autoorient(self):
|
def autoorient(self):
|
||||||
return self.options["autoorient"]
|
return self.options["auto-orient"]
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
source, target = os.path.join(self.base_dir, self.name), os.path.join(self.target_dir, self.name)
|
source, target = os.path.join(self.base_dir, self.name), os.path.join(self.target_dir, self.name)
|
||||||
@ -151,15 +151,10 @@ def main():
|
|||||||
|
|
||||||
error(isinstance(settings, dict), "Your settings.yaml should be a dict")
|
error(isinstance(settings, dict), "Your settings.yaml should be a dict")
|
||||||
error(settings.get("title"), "You should specify a title in your main settings.yaml")
|
error(settings.get("title"), "You should specify a title in your main settings.yaml")
|
||||||
|
|
||||||
if settings.get("auto-orient"):
|
if settings.get("gm_settings"):
|
||||||
global DEFAULT_GM_AUTOORIENT
|
gm_settings.update( settings.get("gm_settings") )
|
||||||
DEFAULT_GM_AUTOORIENT = settings.get("auto-orient")
|
|
||||||
|
|
||||||
if settings.get("quality"):
|
|
||||||
global DEFAULT_GM_QUALITY
|
|
||||||
DEFAULT_GM_QUALITY = settings.get("quality")
|
|
||||||
|
|
||||||
front_page_galleries_cover = []
|
front_page_galleries_cover = []
|
||||||
|
|
||||||
dirs = filter(lambda x: x not in (".", "..") and os.path.isdir(x) and os.path.exists(os.path.join(os.getcwd(), x, "settings.yaml")), os.listdir(os.getcwd()))
|
dirs = filter(lambda x: x not in (".", "..") and os.path.isdir(x) and os.path.exists(os.path.join(os.getcwd(), x, "settings.yaml")), os.listdir(os.getcwd()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user