Mercurial > kallithea
changeset 8006:0cfd77281853
cleanup: convert some StringIO use to use the py3 compatible io module
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 25 Nov 2019 02:46:02 +0100 |
parents | 5a971de9741c |
children | d10caf435170 |
files | kallithea/bin/kallithea_cli_base.py kallithea/tests/vcs/test_archives.py |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_base.py Sun Nov 24 21:19:03 2019 +0100 +++ b/kallithea/bin/kallithea_cli_base.py Mon Nov 25 02:46:02 2019 +0100 @@ -12,8 +12,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import cStringIO import functools +import io import logging.config import os import re @@ -44,7 +44,7 @@ return m.group(0) with open(ini_file_name) as f: - return re.sub(r'^\[([^:]+):(.*)]', repl, f.read(), flags=re.MULTILINE) + return re.sub(r'^\[([^:]+):(.*)]', repl, f.read().decode(), flags=re.MULTILINE) # This placeholder is the main entry point for the kallithea-cli command @@ -71,8 +71,8 @@ def runtime_wrapper(config_file, *args, **kwargs): path_to_ini_file = os.path.realpath(config_file) kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file) - config_bytes = read_config(path_to_ini_file, strip_section_prefix=annotated.__name__) - logging.config.fileConfig(cStringIO.StringIO(config_bytes)) + config_string = read_config(path_to_ini_file, strip_section_prefix=annotated.__name__) + logging.config.fileConfig(io.StringIO(config_string)) if config_file_initialize_app: kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG)
--- a/kallithea/tests/vcs/test_archives.py Sun Nov 24 21:19:03 2019 +0100 +++ b/kallithea/tests/vcs/test_archives.py Mon Nov 25 02:46:02 2019 +0100 @@ -1,6 +1,6 @@ import datetime +import io import os -import StringIO import tarfile import tempfile import zipfile @@ -70,7 +70,7 @@ tmppath = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_default_stream-')[1] with open(tmppath, 'wb') as stream: self.tip.fill_archive(stream=stream) - mystream = StringIO.StringIO() + mystream = io.BytesIO() self.tip.fill_archive(stream=mystream) mystream.seek(0) with open(tmppath, 'rb') as f: