Skip to content

Commit

Permalink
\gopinath-langote#91 Support working tree
Browse files Browse the repository at this point in the history
Fix lint
  • Loading branch information
AdeshAtole committed Jun 11, 2019
1 parent e25126f commit 5554fff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions onebuild/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@
from .utils import DASH, sample_yaml_file


def __get_project_config(working_directory, build_file_name):
potential_path = os.path.join(working_directory, build_file_name)
if os.path.exists(potential_path) and os.path.isfile(potential_path):
return os.path.abspath(potential_path)
else:
parent = os.path.abspath(os.path.join(working_directory,
os.path.pardir))
if(parent == working_directory):
return None
return __get_project_config(parent, build_file_name)

def parse_project_config(build_file_name):
if os.path.exists(build_file_name):
with open(build_file_name, 'r') as stream:
project_config_path = __get_project_config(os.getcwd(), build_file_name)
if project_config_path is not None:
with open(project_config_path, 'r') as stream:
try:
yaml = YAML(typ="safe")
content = yaml.load(stream)
Expand All @@ -37,7 +49,7 @@ def __command_list__(raw_string):


def __file_not_found_error_message__(build_file_name):
return "No '" + build_file_name + "' file found in current directory."
return "No '" + build_file_name + "' file found in working tree."


def __parsing_error_message__(build_file_name):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_1build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_should_fail_if_yaml_file_is_not_present(capsys):
captured = capsys.readouterr()

invalid_file_error_message = \
"No 'tests/data/1build.yaml' file found in current directory.\n"
"No 'tests/data/1build.yaml' file found in working tree.\n"

assert invalid_file_error_message in captured.out

Expand Down

0 comments on commit 5554fff

Please sign in to comment.