From 218e9706028e8a76e87c1fe4d931b4cc3b4f9dda Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Tue, 8 Dec 2015 08:06:47 +0100 Subject: [PATCH] [mod] more explicit error message --- prosopopoee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prosopopoee b/prosopopoee index c8f8073..d1c44d3 100755 --- a/prosopopoee +++ b/prosopopoee @@ -16,11 +16,12 @@ def error(test, error_message): if not test: sys.stderr.write(error_message) sys.stderr.write("\n") + sys.stderr.write("Abort.\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") + error(os.path.exists(os.path.join(os.getcwd(), "settings.yaml")), "I can't find a settings.yaml in the current working directory") settings = yaml.safe_load(open("settings.yaml", "r")) @@ -33,12 +34,12 @@ def main(): 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())) - error(dirs, "I can't find at least one directory with a settings.yaml in the current working directory, you don't have any gallery?\nAbort") + error(dirs, "I can't find at least one directory with a settings.yaml in the current working directory, you don't have any gallery?") for gallery in dirs: - gallery_settings = yaml.safe_load(open(os.path.join(os.getcwd(), gallery, "settings.yaml")), "r") + gallery_settings = yaml.safe_load(open(os.path.join(os.getcwd(), gallery, "settings.yaml"), "r")) - error(isinstance(gallery_settings, dict), "Your settings.yaml should be a dict") + error(isinstance(gallery_settings, dict), "Your %s should be a dict" % (os.path.join(gallery, "settings.yaml"))) error(gallery_settings.get("title"), "You should specify a title in %s" % (os.path.join(gallery, "settings.yaml"))) error(gallery_settings.get("cover"), "You should specify a path to a cover picture in %s" % (os.path.join(gallery, "settings.yaml")))