mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-12 17:14:22 -07:00
[PR #9324/6cd3f79e backport][stable-10] lookup plugins: use f-strings (#9367)
lookup plugins: use f-strings (#9324)
* lookup plugins: use f-strings
* add changelog frag
* manual change for few occurrences
* Update plugins/lookup/dependent.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* adjustment from review
* no f-string for you
* Update plugins/lookup/dependent.py
Co-authored-by: Felix Fontein <felix@fontein.de>
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 6cd3f79e19
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
74bd7f1471
commit
a5c448d6e8
31 changed files with 165 additions and 149 deletions
|
@ -158,7 +158,7 @@ def file_props(root, path):
|
|||
try:
|
||||
st = os.lstat(abspath)
|
||||
except OSError as e:
|
||||
display.warning('filetree: Error using stat() on path %s (%s)' % (abspath, e))
|
||||
display.warning(f'filetree: Error using stat() on path {abspath} ({e})')
|
||||
return None
|
||||
|
||||
ret = dict(root=root, path=path)
|
||||
|
@ -172,7 +172,7 @@ def file_props(root, path):
|
|||
ret['state'] = 'file'
|
||||
ret['src'] = abspath
|
||||
else:
|
||||
display.warning('filetree: Error file type of %s is not supported' % abspath)
|
||||
display.warning(f'filetree: Error file type of {abspath} is not supported')
|
||||
return None
|
||||
|
||||
ret['uid'] = st.st_uid
|
||||
|
@ -185,7 +185,7 @@ def file_props(root, path):
|
|||
ret['group'] = to_text(grp.getgrgid(st.st_gid).gr_name)
|
||||
except KeyError:
|
||||
ret['group'] = st.st_gid
|
||||
ret['mode'] = '0%03o' % (stat.S_IMODE(st.st_mode))
|
||||
ret['mode'] = f'0{stat.S_IMODE(st.st_mode):03o}'
|
||||
ret['size'] = st.st_size
|
||||
ret['mtime'] = st.st_mtime
|
||||
ret['ctime'] = st.st_ctime
|
||||
|
@ -212,7 +212,7 @@ class LookupModule(LookupBase):
|
|||
term_file = os.path.basename(term)
|
||||
dwimmed_path = self._loader.path_dwim_relative(basedir, 'files', os.path.dirname(term))
|
||||
path = os.path.join(dwimmed_path, term_file)
|
||||
display.debug("Walking '{0}'".format(path))
|
||||
display.debug(f"Walking '{path}'")
|
||||
for root, dirs, files in os.walk(path, topdown=True):
|
||||
for entry in dirs + files:
|
||||
relpath = os.path.relpath(os.path.join(root, entry), path)
|
||||
|
@ -221,7 +221,7 @@ class LookupModule(LookupBase):
|
|||
if relpath not in [entry['path'] for entry in ret]:
|
||||
props = file_props(path, relpath)
|
||||
if props is not None:
|
||||
display.debug(" found '{0}'".format(os.path.join(path, relpath)))
|
||||
display.debug(f" found '{os.path.join(path, relpath)}'")
|
||||
ret.append(props)
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue