39 lines
1.1 KiB
Python
Executable File
39 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os
|
|
import sys
|
|
import yaml
|
|
|
|
|
|
|
|
def error(test, error_message):
|
|
if not test:
|
|
sys.stderr.write(error_message)
|
|
sys.stderr.write("\n")
|
|
sys.exit(1)
|
|
|
|
|
|
def main():
|
|
error(os.path.exists(os.path.join(os.getcwd(), "settings.yaml")), "I can't find a settings.yaml in the current working directory, abort")
|
|
|
|
settings = yaml.safe_load("settings.yaml")
|
|
|
|
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")
|
|
|
|
title = settings["title"]
|
|
sub_title = settings.get("sub_title", "")
|
|
|
|
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()))
|
|
|
|
if not dirs:
|
|
sys.stderr.write("I can't find at least one directory with a settings.yaml in the current working directory, you don't have any gallery?\nAbort\n")
|
|
sys.exit(1)
|
|
|
|
if not os.path.exists("build"):
|
|
os.makedirs("build")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|