Skip to content

Commit 74aebae

Browse files
committed
switch from io.open to open
With this extension only supporting Python 3, there is no longer a need to use `io.open` for opening files. Switching to use `open`. Signed-off-by: James Knight <[email protected]>
1 parent 91d5a6c commit 74aebae

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

sphinxcontrib/confluencebuilder/builder.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from sphinxcontrib.confluencebuilder.util import first
3939
from sphinxcontrib.confluencebuilder.util import handle_cli_file_subset
4040
from sphinxcontrib.confluencebuilder.writer import ConfluenceWriter
41-
import io
4241
import os
4342
import tempfile
4443

@@ -477,7 +476,7 @@ def write_doc(self, docname, doctree):
477476
if self.writer.output is not None:
478477
ensuredir(path.dirname(outfilename))
479478
try:
480-
with io.open(outfilename, 'w', encoding='utf-8') as file:
479+
with open(outfilename, 'w', encoding='utf-8') as file:
481480
if self.writer.output:
482481
file.write(self.writer.output)
483482
except (IOError, OSError) as err:
@@ -733,7 +732,7 @@ def finish(self):
733732
docfile = path.join(self.outdir, self.file_transform(docname))
734733

735734
try:
736-
with io.open(docfile, 'r', encoding='utf-8') as file:
735+
with open(docfile, 'r', encoding='utf-8') as file:
737736
output = file.read()
738737
self.publish_doc(docname, output)
739738

@@ -864,7 +863,7 @@ def _generate_special_document(self, docname, generator):
864863
fname = path.join(self.env.srcdir,
865864
self.config.confluence_header_file)
866865
try:
867-
with io.open(fname, encoding='utf-8') as file:
866+
with open(fname, encoding='utf-8') as file:
868867
header_template_data = file.read() + '\n'
869868
except (IOError, OSError) as err:
870869
self.warn('error reading file {}: {}'.format(fname, err))
@@ -886,7 +885,7 @@ def _generate_special_document(self, docname, generator):
886885
fname = path.join(self.env.srcdir,
887886
self.config.confluence_footer_file)
888887
try:
889-
with io.open(fname, encoding='utf-8') as file:
888+
with open(fname, encoding='utf-8') as file:
890889
footer_template_data = file.read() + '\n'
891890
except (IOError, OSError) as err:
892891
self.warn('error reading file {}: {}'.format(fname, err))
@@ -902,7 +901,7 @@ def _generate_special_document(self, docname, generator):
902901
# generate/replace the document in the output directory
903902
fname = path.join(self.outdir, docname + self.file_suffix)
904903
try:
905-
with io.open(fname, 'w', encoding='utf-8') as f:
904+
with open(fname, 'w', encoding='utf-8') as f:
906905
f.write(self._cached_header_data)
907906
generator(self, docname, f)
908907
f.write(self._cached_footer_data)

sphinxcontrib/confluencebuilder/logger.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from contextlib import suppress
66
from sphinx.util import logging
77
from sphinx.util.console import bold # pylint: disable=no-name-in-module
8-
import io
98
import sys
109

1110

@@ -118,7 +117,7 @@ def trace(container, data):
118117
This is solely for manually debugging unexpected scenarios.
119118
"""
120119
try:
121-
with io.open('trace.log', 'a', encoding='utf-8') as file:
120+
with open('trace.log', 'a', encoding='utf-8') as file:
122121
file.write(u'[%s]\n' % container)
123122
file.write(data)
124123
file.write(u'\n')

sphinxcontrib/confluencebuilder/translator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from sphinxcontrib.confluencebuilder.util import convert_length
1616
from sphinxcontrib.confluencebuilder.util import extract_length
1717
from sphinxcontrib.confluencebuilder.util import remove_nonspace_control_chars
18-
import io
1918
import sys
2019

2120

@@ -92,7 +91,7 @@ def depart_document(self, node):
9291
header_file = path.join(self.builder.env.srcdir,
9392
self.builder.config.confluence_header_file)
9493
try:
95-
with io.open(header_file, encoding='utf-8') as file:
94+
with open(header_file, encoding='utf-8') as file:
9695
header_template_data = file.read()
9796
except (IOError, OSError) as err:
9897
self.warn('error reading file {}: {}'.format(header_file, err))
@@ -115,7 +114,7 @@ def depart_document(self, node):
115114
footer_file = path.join(self.builder.env.srcdir,
116115
self.builder.config.confluence_footer_file)
117116
try:
118-
with io.open(footer_file, encoding='utf-8') as file:
117+
with open(footer_file, encoding='utf-8') as file:
119118
footer_template_data = file.read()
120119
except (IOError, OSError) as err:
121120
self.warn('error reading file {}: {}'.format(footer_file, err))

tests/lib/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import builtins
1717
import http.server as http_server
1818
import inspect
19-
import io
2019
import json
2120
import os
2221
import shutil
@@ -455,7 +454,7 @@ def parse(filename, dirname=None):
455454

456455
target += '.conf'
457456

458-
with io.open(target, encoding='utf-8') as fp:
457+
with open(target, encoding='utf-8') as fp:
459458
soup = BeautifulSoup(fp, 'html.parser')
460459
yield soup
461460

tests/test_sandbox.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from tests.lib import prepare_dirs
99
from tests.lib import prepare_sphinx
1010
import argparse
11-
import io
1211
import os
1312
import sys
1413

@@ -48,7 +47,7 @@ def process_raw_upload(target_sandbox):
4847
'labels': [],
4948
}
5049

51-
with io.open(raw_file, 'r', encoding='utf-8') as f:
50+
with open(raw_file, 'r', encoding='utf-8') as f:
5251
data['content'] = f.read()
5352

5453
print('[sandbox] publishing page...')

tests/unit-tests/test_config_prev_next.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Copyright 2020-2023 Sphinx Confluence Builder Contributors (AUTHORS)
33

44
from tests.lib.testcase import ConfluenceTestCase
5-
import io
65
import os
76

87

@@ -58,7 +57,7 @@ def _character_check(self, name, output, expected):
5857
self.assertTrue(os.path.exists(test_path),
5958
'missing output file: {}'.format(test_path))
6059

61-
with io.open(test_path, encoding='utf8') as test_file:
60+
with open(test_path, encoding='utf8') as test_file:
6261
data = ''.join([o.strip() + '\n' for o in test_file.readlines()])
6362
for char, count in expected.items():
6463
found = data.count(char)

0 commit comments

Comments
 (0)