|
|
|
@ -94,7 +94,16 @@ class VarsModule(BaseVarsPlugin):
|
|
|
|
|
|
|
|
|
|
b_path = to_bytes(os.path.join(path, name))
|
|
|
|
|
found = []
|
|
|
|
|
for ext in C.YAML_FILENAME_EXTENSIONS + ['']:
|
|
|
|
|
|
|
|
|
|
# first look for w/o extensions
|
|
|
|
|
if os.path.exists(b_path):
|
|
|
|
|
if os.path.isdir(b_path):
|
|
|
|
|
found.extend(self._get_dir_files(b_path))
|
|
|
|
|
else:
|
|
|
|
|
found.append(b_path)
|
|
|
|
|
else:
|
|
|
|
|
# add valid extensions to name
|
|
|
|
|
for ext in C.YAML_FILENAME_EXTENSIONS:
|
|
|
|
|
|
|
|
|
|
if '.' in ext:
|
|
|
|
|
full_path = b_path + to_bytes(ext)
|
|
|
|
@ -103,18 +112,24 @@ class VarsModule(BaseVarsPlugin):
|
|
|
|
|
else:
|
|
|
|
|
full_path = b_path
|
|
|
|
|
|
|
|
|
|
if os.path.exists(full_path):
|
|
|
|
|
self._display.debug("\tfound %s" % to_text(full_path))
|
|
|
|
|
if os.path.isdir(full_path):
|
|
|
|
|
# matched dir name, so use all files included recursively
|
|
|
|
|
for spath in os.listdir(full_path):
|
|
|
|
|
if spath.startswith('.'):
|
|
|
|
|
continue
|
|
|
|
|
full_spath = os.path.join(full_path, spath)
|
|
|
|
|
if os.path.isdir(full_spath):
|
|
|
|
|
found.extend(self._find_vars_files(full_spath, ''))
|
|
|
|
|
else:
|
|
|
|
|
found.append(full_spath)
|
|
|
|
|
else:
|
|
|
|
|
if os.path.exists(full_path) and os.path.isfile(full_path):
|
|
|
|
|
found.append(full_path)
|
|
|
|
|
break
|
|
|
|
|
return found
|
|
|
|
|
|
|
|
|
|
def _get_dir_files(self, path):
|
|
|
|
|
|
|
|
|
|
found = []
|
|
|
|
|
for spath in os.listdir(path):
|
|
|
|
|
if not spath.startswith('.'): # skip hidden
|
|
|
|
|
|
|
|
|
|
ext = os.path.splitext()[-1]
|
|
|
|
|
full_spath = os.path.join(path, spath)
|
|
|
|
|
|
|
|
|
|
if os.path.isdir(full_spath) and not ext: # recursive search if dir
|
|
|
|
|
found.extend(self._get_dir_files(full_spath))
|
|
|
|
|
elif os.path.isfile(full_spath) and (not ext or ext in C.YAML_FILENAME_EXTENSIONS):
|
|
|
|
|
# only consider files with valid extensions or no extension
|
|
|
|
|
found.append(full_spath)
|
|
|
|
|
|
|
|
|
|
return found
|
|
|
|
|