From e0f827894382eead900f1628f1ddd597b026d2e2 Mon Sep 17 00:00:00 2001 From: Gopinath Langote Date: Thu, 25 Apr 2019 16:39:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9D=8C=20Handle=20file=20format=20error=20Is?= =?UTF-8?q?sue:=20#10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1build | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/1build b/1build index 437a98f5..4c07109a 100755 --- a/1build +++ b/1build @@ -82,11 +82,12 @@ def parse_project_config(): with open("1build.yaml", 'r') as stream: try: content = yaml.safe_load(stream) - except yaml.YAMLError, exc: + return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"]))) + except: raise ValueError( - "Error in parsing `1build.yaml` config file. Make sure file is in correct format. \n\n" + exc.__str__() + "Error in parsing `1build.yaml` config file. Make sure file is in correct format. \nSample format is: \n\n" + + "---------------------------------------------------\n" + sample_yaml_file() + "---------------------------------------------------\n" ) - return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"]))) else: raise ValueError("No `1build.yaml` file found in current directory.") @@ -102,4 +103,16 @@ def command_to_run(arguments): return arguments[1] +def sample_yaml_file(): + return "project: JUnit5" + "\n" + \ + "commands:" + "\n" + \ + " - build:" + "\n" + \ + " description: build the project" + "\n" + \ + " cmd: ./gradlew clean build" + "\n" + \ + " - lint:" + "\n" + \ + " description: fix the lint" + "\n" + \ + " cmd: ./gradlew spotlessApply" + "\n" + \ + "" + + run(sys.argv)