Skip to content
Snippets Groups Projects
Commit 6134fd4e authored by Jonathan Maw's avatar Jonathan Maw
Browse files

cli.py: Use utils' search upwards helper when searching for project.conf

parent c8229c9c
No related branches found
No related tags found
Loading
...@@ -59,18 +59,9 @@ def complete_target(args, incomplete): ...@@ -59,18 +59,9 @@ def complete_target(args, incomplete):
:return: all the possible user-specified completions for the param :return: all the possible user-specified completions for the param
""" """
from .. import utils
project_conf = 'project.conf' project_conf = 'project.conf'
def ensure_project_dir(directory):
directory = os.path.abspath(directory)
while not os.path.isfile(os.path.join(directory, project_conf)):
parent_dir = os.path.dirname(directory)
if directory == parent_dir:
break
directory = parent_dir
return directory
# First resolve the directory, in case there is an # First resolve the directory, in case there is an
# active --directory/-C option # active --directory/-C option
# #
...@@ -89,7 +80,7 @@ def complete_target(args, incomplete): ...@@ -89,7 +80,7 @@ def complete_target(args, incomplete):
else: else:
# Check if this directory or any of its parent directories # Check if this directory or any of its parent directories
# contain a project config file # contain a project config file
base_directory = ensure_project_dir(base_directory) base_directory = utils._search_upward_for_file(base_directory, project_conf)
# Now parse the project.conf just to find the element path, # Now parse the project.conf just to find the element path,
# this is unfortunately a bit heavy. # this is unfortunately a bit heavy.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment