From 5564a44d0d97035aa1af87489daf5fb0f7a0b49e Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Sat, 27 Jul 2024 20:13:10 +0200 Subject: [PATCH] style: use list comprehensions and unpacking --- nyacme/__main__.py | 3 ++- nyacme/handlers/cloudflare.py | 4 ++-- nyacme/handlers/he.py | 3 +-- nyacme/hook.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nyacme/__main__.py b/nyacme/__main__.py index f6d6b39..128a96f 100644 --- a/nyacme/__main__.py +++ b/nyacme/__main__.py @@ -64,7 +64,8 @@ def main() -> None: '--type', 'EC', # '--force', 'issue', - ] + uacme_domains, env=env) + *uacme_domains, + ], env=env) if res.returncode == 0: acquired = True diff --git a/nyacme/handlers/cloudflare.py b/nyacme/handlers/cloudflare.py index 4f2e266..f815c94 100644 --- a/nyacme/handlers/cloudflare.py +++ b/nyacme/handlers/cloudflare.py @@ -17,12 +17,12 @@ class CloudflareHandler(Handler): self.secret = config.get_secret('cloudflare') servers = dns.resolver.resolve(zone_name, 'NS') - self.nameservers = list(map(lambda rdata: str(rdata.target).strip('.'), servers)) + self.nameservers = [ str(rdata.target).strip('.') for rdata in servers ] def run(self, args: list[str]) -> Any: env = os.environ.copy() env['CF_API_TOKEN'] = self.secret - res = subprocess.run(['flarectl', '--json'] + args, check=True, stdout=subprocess.PIPE, env=env) + res = subprocess.run(['flarectl', '--json', *args], check=True, stdout=subprocess.PIPE, env=env) try: return json.loads(res.stdout) except json.decoder.JSONDecodeError as ex: diff --git a/nyacme/handlers/he.py b/nyacme/handlers/he.py index e531821..cf2552e 100644 --- a/nyacme/handlers/he.py +++ b/nyacme/handlers/he.py @@ -7,10 +7,9 @@ from .base import Handler class HEHandler(Handler): - nameservers = ['ns1.he.net', 'ns2.he.net', 'ns3.he.net', 'ns4.he.net', 'ns5.he.net'] - def __init__(self, zone_name: str, config: Config, token: str) -> None: super().__init__(zone_name, config, token) + self.nameservers = ['ns1.he.net', 'ns2.he.net', 'ns3.he.net', 'ns4.he.net', 'ns5.he.net'] self.password = config.get_secret('he') def set_record(self, record_name: str, value: str) -> Any: diff --git a/nyacme/hook.py b/nyacme/hook.py index 0f3cd1a..cdc9792 100644 --- a/nyacme/hook.py +++ b/nyacme/hook.py @@ -62,7 +62,7 @@ def main() -> None: log.info('checking DNS (attempt %d/5)', i+1) try: res = resolver.resolve(record_name, 'TXT') - values = list(map(lambda rdata: rdata.to_text().strip('"'), res)) + values = [ rdata.to_text().strip('"') for rdata in res ] except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): values = [] log.info('response from DNS: %s', values)