Skip to content

Commit

Permalink
applied ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
infinityofspace committed Nov 9, 2024
1 parent c7be4e8 commit d857d36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
34 changes: 21 additions & 13 deletions certbot_dns_porkbun/cert/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def add_parser_arguments(cls, add: callable) -> None:
:param add: method handling the argument adding to the cli
"""

super(Authenticator, cls).add_parser_arguments(add, default_propagation_seconds=DEFAULT_PROPAGATION_SECONDS)
super(Authenticator, cls).add_parser_arguments(
add, default_propagation_seconds=DEFAULT_PROPAGATION_SECONDS
)
add("credentials", help="Porkbun credentials INI file.")
add("key", help="Porkbun API key (overwrites credentials file)")
add("secret", help="Porkbun API key secret (overwrites credentials file)")
Expand All @@ -57,9 +59,10 @@ def _setup_credentials(self) -> None:
if self.conf("key") and self.conf("secret"):
return

self._configure_file('credentials',
'Absolute path to Porkbun credentials INI file')
dns_common.validate_file_permissions(self.conf('credentials'))
self._configure_file(
"credentials", "Absolute path to Porkbun credentials INI file"
)
dns_common.validate_file_permissions(self.conf("credentials"))
self.credentials = self._configure_credentials(
"credentials",
"Porkbun credentials INI file",
Expand All @@ -85,9 +88,11 @@ def _perform(self, domain: str, validation_name: str, validation: str) -> None:

propagation_seconds = self.conf("propagation_seconds")
if propagation_seconds < 600:
logging.warning("The propagation time is less than Porkbun DNS TTL minimum of 600 seconds. Subsequent "
"challenges for same domain may fail. Try increasing the propagation time if you encounter "
"issues.")
logging.warning(
"The propagation time is less than Porkbun DNS TTL minimum of 600 seconds. Subsequent "
"challenges for same domain may fail. Try increasing the propagation time if you encounter "
"issues."
)

# replace wildcard in domain
domain = domain.replace("*", "")
Expand All @@ -104,11 +109,12 @@ def _perform(self, domain: str, validation_name: str, validation: str) -> None:
name = extract_result.subdomain

try:
self.record_ids_to_root_domain[validation] = (client.create_dns_record(root_domain,
DNSRecordType.TXT,
validation,
name=name),
root_domain)
self.record_ids_to_root_domain[validation] = (
client.create_dns_record(
root_domain, DNSRecordType.TXT, validation, name=name
),
root_domain,
)

except Exception as e:
raise errors.PluginError(e)
Expand All @@ -130,7 +136,9 @@ def _cleanup(self, domain: str, validation_name: str, validation: str) -> None:

try:
if not self._get_porkbun_client().delete_dns_record(root_domain, record_id):
raise errors.PluginError("TXT for domain {} was not deleted".format(domain))
raise errors.PluginError(
"TXT for domain {} was not deleted".format(domain)
)
except Exception as e:
raise errors.PluginError(e)

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"Topic :: Security",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Utilities",
"Topic :: System :: Systems Administration"
"Topic :: System :: Systems Administration",
],
packages=find_packages(),
python_requires=">=3.9",
Expand All @@ -35,11 +35,11 @@
"certbot>=1.18.0,<4.0",
"pkb_client>=2.0,<3.0",
"dnspython>=2.0.0,<3.0",
"tldextract>=5.1.2,<6.0"
"tldextract>=5.1.2,<6.0",
],
entry_points={
"certbot.plugins": [
"dns-porkbun = certbot_dns_porkbun.cert.client:Authenticator",
]
}
},
)

0 comments on commit d857d36

Please sign in to comment.