Replace io.open with the built-in.

As of Python 3, io.open is an alias for the built-in open function.
This commit is contained in:
Mads Jensen
2024-12-14 11:29:40 +01:00
parent 0f0000298b
commit 8a69b2f1d9
4 changed files with 8 additions and 11 deletions
@@ -1,6 +1,5 @@
"""A class that performs HTTP-01 challenges for Nginx"""
import io
import logging
from typing import Any
from typing import List
@@ -139,7 +138,7 @@ class NginxHttp01(common.ChallengePerformer):
self.configurator.reverter.register_file_creation(
True, self.challenge_conf)
with io.open(self.challenge_conf, "w", encoding="utf-8") as new_conf:
with open(self.challenge_conf, "w", encoding="utf-8") as new_conf:
nginxparser.dump(config, new_conf)
def _default_listen_addresses(self) -> List[Addr]:
@@ -2,7 +2,6 @@
import copy
import functools
import glob
import io
import logging
import re
from typing import Any
@@ -211,7 +210,7 @@ class NginxParser:
if item in self.parsed and not override:
continue
try:
with io.open(item, "r", encoding="utf-8") as _file:
with open(item, "r", encoding="utf-8") as _file:
parsed = nginxparser.load(_file)
self.parsed[item] = parsed
trees.append(parsed)
@@ -255,7 +254,7 @@ class NginxParser:
continue
out = nginxparser.dumps(tree)
logger.debug('Writing nginx conf tree to %s:\n%s', filename, out)
with io.open(filename, 'w', encoding='utf-8') as _file:
with open(filename, 'w', encoding='utf-8') as _file:
_file.write(out)
except IOError:
@@ -431,7 +430,7 @@ class NginxParser:
def _parse_ssl_options(ssl_options: Optional[str]) -> List[UnspacedList]:
if ssl_options is not None:
try:
with io.open(ssl_options, "r", encoding="utf-8") as _file:
with open(ssl_options, "r", encoding="utf-8") as _file:
return nginxparser.load(_file)
except IOError:
logger.warning("Missing NGINX TLS options file: %s", ssl_options)