mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
plugins: replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting (#9379)
* Replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting. * Improve formulation. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Use more f-strings. * Remove unicode prefix for strings. --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
4b4e4b7e0a
commit
2203560867
34 changed files with 111 additions and 99 deletions
|
@ -178,7 +178,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
try:
|
||||
self._nmap = get_bin_path('nmap')
|
||||
except ValueError as e:
|
||||
raise AnsibleParserError(f'nmap inventory plugin requires the nmap cli tool to work: {to_native(e)}')
|
||||
raise AnsibleParserError(f'nmap inventory plugin requires the nmap cli tool to work: {e}')
|
||||
|
||||
super(InventoryModule, self).parse(inventory, loader, path, cache=cache)
|
||||
|
||||
|
@ -259,7 +259,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
try:
|
||||
t_stdout = to_text(stdout, errors='surrogate_or_strict')
|
||||
except UnicodeError as e:
|
||||
raise AnsibleParserError(f'Invalid (non unicode) input returned: {to_native(e)}')
|
||||
raise AnsibleParserError(f'Invalid (non unicode) input returned: {e}')
|
||||
|
||||
for line in t_stdout.splitlines():
|
||||
hits = self.find_host.match(line)
|
||||
|
@ -300,7 +300,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
results[-1]['ports'] = ports
|
||||
|
||||
except Exception as e:
|
||||
raise AnsibleParserError(f"failed to parse {to_native(path)}: {to_native(e)} ")
|
||||
raise AnsibleParserError(f"failed to parse {to_native(path)}: {e} ")
|
||||
|
||||
if cache_needs_update:
|
||||
self._cache[cache_key] = results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue