mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ensure proper typing of path, cause py3 listdir
since now output is based on input, we need to make sure its always same fixes #25856
This commit is contained in:
parent
06c21b4bec
commit
e08f068dca
1 changed files with 3 additions and 3 deletions
|
@ -99,7 +99,7 @@ class VarsModule(BaseVarsPlugin):
|
||||||
# first look for w/o extensions
|
# first look for w/o extensions
|
||||||
if os.path.exists(b_path):
|
if os.path.exists(b_path):
|
||||||
if os.path.isdir(b_path):
|
if os.path.isdir(b_path):
|
||||||
found.extend(self._get_dir_files(b_path))
|
found.extend(self._get_dir_files(to_text(b_path)))
|
||||||
else:
|
else:
|
||||||
found.append(b_path)
|
found.append(b_path)
|
||||||
else:
|
else:
|
||||||
|
@ -122,14 +122,14 @@ class VarsModule(BaseVarsPlugin):
|
||||||
|
|
||||||
found = []
|
found = []
|
||||||
for spath in os.listdir(path):
|
for spath in os.listdir(path):
|
||||||
if not spath.startswith('.') and not spath.endswith('~'): # skip hidden and backups
|
if not spath.startswith(b'.') and not spath.endswith(b'~'): # skip hidden and backups
|
||||||
|
|
||||||
ext = os.path.splitext(spath)[-1]
|
ext = os.path.splitext(spath)[-1]
|
||||||
full_spath = os.path.join(path, spath)
|
full_spath = os.path.join(path, spath)
|
||||||
|
|
||||||
if os.path.isdir(full_spath) and not ext: # recursive search if dir
|
if os.path.isdir(full_spath) and not ext: # recursive search if dir
|
||||||
found.extend(self._get_dir_files(full_spath))
|
found.extend(self._get_dir_files(full_spath))
|
||||||
elif os.path.isfile(full_spath) and (not ext or ext in C.YAML_FILENAME_EXTENSIONS):
|
elif os.path.isfile(full_spath) and (not ext or to_text(ext) in C.YAML_FILENAME_EXTENSIONS):
|
||||||
# only consider files with valid extensions or no extension
|
# only consider files with valid extensions or no extension
|
||||||
found.append(full_spath)
|
found.append(full_spath)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue