Move find_candidates_in_parent_dirs() into a config module so that config doesn't import from cli.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
89be7f1fa7
commit
fe5daf860d
2 changed files with 21 additions and 22 deletions
|
|
@ -36,25 +36,6 @@ def yesno(prompt, default=None):
|
|||
return None
|
||||
|
||||
|
||||
def find_candidates_in_parent_dirs(filenames, path):
|
||||
"""
|
||||
Given a directory path to start, looks for filenames in the
|
||||
directory, and then each parent directory successively,
|
||||
until found.
|
||||
|
||||
Returns tuple (candidates, path).
|
||||
"""
|
||||
candidates = [filename for filename in filenames
|
||||
if os.path.exists(os.path.join(path, filename))]
|
||||
|
||||
if len(candidates) == 0:
|
||||
parent_dir = os.path.join(path, '..')
|
||||
if os.path.abspath(parent_dir) != os.path.abspath(path):
|
||||
return find_candidates_in_parent_dirs(filenames, parent_dir)
|
||||
|
||||
return (candidates, path)
|
||||
|
||||
|
||||
def split_buffer(reader, separator):
|
||||
"""
|
||||
Given a generator which yields strings and a separator string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue