Reformat everything.

This commit is contained in:
Felix Fontein
2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View File

@@ -57,6 +57,7 @@ HAVE_DNS = False
try:
import dns.resolver
from dns.exception import DNSException
HAVE_DNS = True
except ImportError:
pass
@@ -73,21 +74,20 @@ from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
if HAVE_DNS is False:
raise AnsibleError("Can't LOOKUP(dnstxt): module dns.resolver is not installed")
real_empty = self.get_option('real_empty')
real_empty = self.get_option("real_empty")
ret = []
for term in terms:
domain = term.split()[0]
string = []
try:
answers = dns.resolver.query(domain, 'TXT')
answers = dns.resolver.query(domain, "TXT")
for rdata in answers:
s = rdata.to_text()
string.append(s[1:-1]) # Strip outside quotes on TXT rdata
@@ -95,18 +95,18 @@ class LookupModule(LookupBase):
except dns.resolver.NXDOMAIN:
if real_empty:
continue
string = 'NXDOMAIN'
string = "NXDOMAIN"
except dns.resolver.Timeout:
if real_empty:
continue
string = ''
string = ""
except dns.resolver.NoAnswer:
if real_empty:
continue
string = ''
string = ""
except DNSException as e:
raise AnsibleError(f"dns.resolver unhandled exception {e}")
ret.append(''.join(string))
ret.append("".join(string))
return ret