From 6262a3a7d1084ebb0dda7f7e49bea25343d25860 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Mon, 1 May 2017 10:23:17 -0600 Subject: [PATCH] Use BytesIO instead of StringIO --- geomagio/Util.py | 4 ++-- geomagio/edge/EdgeFactory.py | 4 ++-- geomagio/iaga2002/IAGA2002Writer.py | 6 +++--- geomagio/pcdcp/PCDCPWriter.py | 6 +++--- geomagio/temperature/TEMPWriter.py | 6 +++--- geomagio/vbf/VBFWriter.py | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/geomagio/Util.py b/geomagio/Util.py index e53d25c25..05eab9d9f 100644 --- a/geomagio/Util.py +++ b/geomagio/Util.py @@ -2,7 +2,7 @@ import pycurl import numpy import os from obspy.core import Stats, Trace -from io import StringIO +from io import BytesIO class ObjectView(object): @@ -161,7 +161,7 @@ def read_url(url, connect_timeout=15, max_redirects=5, timeout=300): except Exception: pass content = None - out = StringIO() + out = BytesIO() curl = pycurl.Curl() try: curl.setopt(pycurl.FOLLOWLOCATION, 1) diff --git a/geomagio/edge/EdgeFactory.py b/geomagio/edge/EdgeFactory.py index 62875bf72..675a27b8d 100644 --- a/geomagio/edge/EdgeFactory.py +++ b/geomagio/edge/EdgeFactory.py @@ -11,7 +11,7 @@ Edge is the USGS earthquake hazard centers replacement for earthworm. from __future__ import absolute_import import sys -from io import StringIO +from io import BytesIO import numpy import numpy.ma import obspy.core @@ -141,7 +141,7 @@ class EdgeFactory(TimeseriesFactory): # need this until https://github.com/obspy/obspy/pull/1179 # replace stdout original_stdout = sys.stdout - temp_stdout = StringIO() + temp_stdout = BytesIO() try: sys.stdout = temp_stdout # get the timeseries diff --git a/geomagio/iaga2002/IAGA2002Writer.py b/geomagio/iaga2002/IAGA2002Writer.py index a0b84a151..e73611baa 100644 --- a/geomagio/iaga2002/IAGA2002Writer.py +++ b/geomagio/iaga2002/IAGA2002Writer.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from builtins import range -from io import StringIO +from io import BytesIO from datetime import datetime import numpy import textwrap @@ -260,7 +260,7 @@ class IAGA2002Writer(object): def format(self, timeseries, channels): """Get an IAGA2002 formatted string. - Calls write() with a StringIO, and returns the output. + Calls write() with a BytesIO, and returns the output. Parameters ---------- @@ -271,7 +271,7 @@ class IAGA2002Writer(object): unicode IAGA2002 formatted string. """ - out = StringIO() + out = BytesIO() writer = IAGA2002Writer() writer.write(out, timeseries, channels) return out.getvalue() diff --git a/geomagio/pcdcp/PCDCPWriter.py b/geomagio/pcdcp/PCDCPWriter.py index 42e91b316..390c2ea15 100644 --- a/geomagio/pcdcp/PCDCPWriter.py +++ b/geomagio/pcdcp/PCDCPWriter.py @@ -3,7 +3,7 @@ from builtins import range import numpy from . import PCDCPParser -from io import StringIO +from io import BytesIO from datetime import datetime from .. import ChannelConverter, TimeseriesUtility from ..TimeseriesFactoryException import TimeseriesFactoryException @@ -165,7 +165,7 @@ class PCDCPWriter(object): def format(self, timeseries, channels): """Get an PCDCP formatted string. - Calls write() with a StringIO, and returns the output. + Calls write() with a BytesIO, and returns the output. Parameters ---------- @@ -179,7 +179,7 @@ class PCDCPWriter(object): unicode PCDCP formatted string. """ - out = StringIO() + out = BytesIO() writer = PCDCPWriter() writer.write(out, timeseries, channels) return out.getvalue() diff --git a/geomagio/temperature/TEMPWriter.py b/geomagio/temperature/TEMPWriter.py index fd38d6fc0..d7dfebe3b 100644 --- a/geomagio/temperature/TEMPWriter.py +++ b/geomagio/temperature/TEMPWriter.py @@ -1,7 +1,7 @@ from builtins import range import numpy -from io import StringIO +from io import BytesIO from datetime import datetime from .. import TimeseriesUtility from ..TimeseriesFactoryException import TimeseriesFactoryException @@ -131,7 +131,7 @@ class TEMPWriter(object): def format(self, timeseries, channels): """Get an temp/volt formatted string. - Calls write() with a StringIO, and returns the output. + Calls write() with a BytesIO, and returns the output. Parameters ---------- @@ -145,7 +145,7 @@ class TEMPWriter(object): unicode temp/volt formatted string. """ - out = StringIO() + out = BytesIO() writer = TEMPWriter() writer.write(out, timeseries, channels) return out.getvalue() diff --git a/geomagio/vbf/VBFWriter.py b/geomagio/vbf/VBFWriter.py index 626d474d3..47794c812 100644 --- a/geomagio/vbf/VBFWriter.py +++ b/geomagio/vbf/VBFWriter.py @@ -1,7 +1,7 @@ from builtins import range import numpy -from io import StringIO +from io import BytesIO from datetime import datetime from .. import ChannelConverter, TimeseriesUtility from ..TimeseriesFactoryException import TimeseriesFactoryException @@ -146,7 +146,7 @@ class VBFWriter(object): def format(self, timeseries, channels): """Get an VBF formatted string. - Calls write() with a StringIO, and returns the output. + Calls write() with a BytesIO, and returns the output. Parameters ---------- @@ -160,7 +160,7 @@ class VBFWriter(object): unicode VBF formatted string. """ - out = StringIO() + out = BytesIO() writer = VBFWriter() writer.write(out, timeseries, channels) return out.getvalue() -- GitLab