Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Import StringIO from six
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-rt committed Oct 24, 2017
1 parent 1126f98 commit 967ff35
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
------------------

- Move ``Products.SiteAccess`` back to `Zope`.
- Import StringIO from six


4.0b1 (2017-09-18)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
],
install_requires=[
'setuptools',
'six',
'AccessControl',
'Acquisition',
'ExtensionClass',
Expand Down
5 changes: 3 additions & 2 deletions src/Signals/threads.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
import thread
import traceback
import time
from cStringIO import StringIO
import traceback

from six.moves import cStringIO as StringIO


def dump_threads():
Expand Down
6 changes: 4 additions & 2 deletions src/ZServer/ClockServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import os
import socket
import time
import StringIO
import asyncore

from ZServer.medusa.http_server import http_request
Expand All @@ -29,6 +28,9 @@
from ZPublisher.HTTPRequest import HTTPRequest


from six import StringIO


def timeslice(period, when=None, t=time.time):
if when is None:
when = t()
Expand Down Expand Up @@ -102,7 +104,7 @@ def __init__(self, method, period=60, user=None, password=None,
self.zhandler = handler

def get_requests_and_response(self):
out = StringIO.StringIO()
out = StringIO()
s_req = '%s %s HTTP/%s' % ('GET', self.method, '1.0')
req = http_request(DummyChannel(self), s_req, 'GET', self.method,
'1.0', self.headers)
Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/FCGIServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

from ZServer import DebugLogger

from cStringIO import StringIO
from tempfile import TemporaryFile
import socket
import string
Expand All @@ -58,6 +57,9 @@
import thread
import base64

from six.moves import cStringIO as StringIO


tz_for_log = compute_timezone_for_log()

# Set various FastCGI constants
Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/FTPRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

from ZPublisher.HTTPRequest import HTTPRequest

from cStringIO import StringIO
import os
from base64 import encodestring
import re


from six.moves import cStringIO as StringIO


class FTPRequest(HTTPRequest):

def __init__(self, path, command, channel, response, stdin=None,
Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/FTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

from ZServer.HTTPResponse import ZServerHTTPResponse
from PubCore.ZEvent import Wakeup
from cStringIO import StringIO
import marshal


from six.moves import cStringIO as StringIO


class FTPResponse(ZServerHTTPResponse):
"""
Response to an FTP command
Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/HTTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from __future__ import absolute_import

import asyncore
from cStringIO import StringIO
import re
import tempfile
import thread
Expand All @@ -45,6 +44,9 @@
from ZServer.Zope2.Startup import config


from six.moves import cStringIO as StringIO


class ZServerHTTPResponse(HTTPResponse):
"Used to push data into a channel's producer fifo"

Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/HTTPServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import posixpath
import time
import socket
from cStringIO import StringIO

from ZServer.PubCore import handle
from ZServer.HTTPResponse import make_response
Expand All @@ -60,6 +59,9 @@
from ZServer import DebugLogger


from six.moves import cStringIO as StringIO


CONTENT_LENGTH = re.compile('Content-Length: ([0-9]+)', re.I)
CONNECTION = re.compile('Connection: (.*)', re.I)
USER_AGENT = re.compile('User-Agent: (.*)', re.I)
Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/PCGIServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import asynchat
import asyncore
from cStringIO import StringIO
from tempfile import TemporaryFile
import socket
import string
Expand All @@ -56,6 +55,9 @@
from ZServer import DebugLogger
from ZServer.Zope2.Startup import config

from six.moves import cStringIO as StringIO


tz_for_log = compute_timezone_for_log()


Expand Down
2 changes: 1 addition & 1 deletion src/ZServer/Testing/threadutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from __future__ import absolute_import

from threading import Thread
from StringIO import StringIO

from Lifetime import loop
from six import StringIO

dummyLOG = StringIO()

Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/ZPublisher/tests/test_pubevents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from StringIO import StringIO
from sys import modules, exc_info
from unittest import TestCase

Expand All @@ -21,6 +20,9 @@
)
from ZServer.ZPublisher.Publish import publish

from six import StringIO


PUBMODULE = 'TEST_testpubevents'

_g = globals()
Expand Down
4 changes: 2 additions & 2 deletions src/ZServer/Zope2/App/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
from __future__ import absolute_import

import os
import cStringIO
import tempfile
import unittest

import ZConfig
from six import moves

import Products
from ZServer.Zope2.Startup import datatypes
Expand Down Expand Up @@ -56,7 +56,7 @@ def load_config_text(self, text):
# of the directory is checked. This handles this in a
# platform-independent way.
schema = self.schema
sio = cStringIO.StringIO(
sio = moves.cStringIO(
text.replace("<<INSTANCE_HOME>>", TEMPNAME))
os.mkdir(TEMPNAME)
os.mkdir(TEMPPRODUCTS)
Expand Down
6 changes: 4 additions & 2 deletions src/ZServer/Zope2/Startup/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
##############################################################################
"""Datatypes for the Zope schema for use with ZConfig."""

import cStringIO
import os
from UserDict import UserDict
import traceback
Expand All @@ -22,6 +21,9 @@
from ZODB.config import ZODBDatabase


from six import moves


def security_policy_implementation(value):
value = value.upper()
ok = ('PYTHON', 'C')
Expand Down Expand Up @@ -91,7 +93,7 @@ def importable_name(name):
package = __import__(n, g, g, component)
return package
except ImportError:
IO = cStringIO.StringIO()
IO = moves.cStringIO()
traceback.print_exc(file=IO)
raise ValueError(
'The object named by "%s" could not be imported\n%s' % (
Expand Down
4 changes: 2 additions & 2 deletions src/ZServer/Zope2/Startup/tests/testStarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from __future__ import absolute_import

import cStringIO
import errno
import logging
import os
Expand All @@ -26,6 +25,7 @@

import ZConfig
from ZConfig.components.logger.tests.test_logger import LoggingTestHelper
from six import moves

from App.config import getConfiguration, setConfiguration
import Products
Expand Down Expand Up @@ -86,7 +86,7 @@ def load_config_text(self, text):
# of the directory is checked. This handles this in a
# platform-independent way.
schema = self.schema
sio = cStringIO.StringIO(
sio = moves.cStringIO(
text.replace("<<INSTANCE_HOME>>", TEMPNAME))
try:
os.mkdir(TEMPNAME)
Expand Down
4 changes: 2 additions & 2 deletions src/ZServer/Zope2/Startup/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
##############################################################################

import os
import cStringIO
import tempfile
import unittest

import ZConfig
from six import moves

from ZServer.Zope2.Startup.options import ZopeOptions

Expand Down Expand Up @@ -47,7 +47,7 @@ def load_config_text(self, text):
# of the directory is checked. This handles this in a
# platform-independent way.
schema = self.schema
sio = cStringIO.StringIO(
sio = moves.cStringIO(
text.replace("<<INSTANCE_HOME>>", TEMPNAME))
os.mkdir(TEMPNAME)
os.mkdir(TEMPVAR)
Expand Down
6 changes: 4 additions & 2 deletions src/ZServer/Zope2/Startup/tests/test_warnfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
##############################################################################

import os
import cStringIO
import tempfile
import unittest
import warnings
Expand All @@ -23,6 +22,9 @@
from ZServer.Zope2.Startup.options import ZopeOptions
import Products

from six import moves


TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")

Expand Down Expand Up @@ -62,7 +64,7 @@ def load_config_text(self, text):
# of the directory is checked. This handles this in a
# platform-independent way.
schema = self.schema
sio = cStringIO.StringIO(
sio = moves.cStringIO(
text.replace("<<INSTANCE_HOME>>", TEMPNAME))
os.mkdir(TEMPNAME)
os.mkdir(TEMPPRODUCTS)
Expand Down
10 changes: 6 additions & 4 deletions src/ZServer/medusa/http_bobo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- Mode: Python; tab-width: 4 -*-

import string
import StringIO
import regex

from six import StringIO


RCS_ID = '$Id$'
VERSION_STRING = string.split(RCS_ID)[2]

Expand Down Expand Up @@ -53,9 +55,9 @@ def handle_request(self, channel):

# this should really be done with with a real producer. just
# have to make sure it can handle all of the file object api.
sin = StringIO.StringIO('')
sout = StringIO.StringIO()
serr = StringIO.StringIO()
sin = StringIO('')
sout = StringIO()
serr = StringIO()

cgi_module_publisher.publish_module(
module_name,
Expand Down
8 changes: 5 additions & 3 deletions src/ZServer/medusa/thread/thread_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import re
import string
import StringIO
import sys
import threading

Expand All @@ -12,6 +11,9 @@
from .. import select_trigger


from six import StringIO


class request_queue(object):

def __init__(self):
Expand Down Expand Up @@ -166,7 +168,7 @@ def handle_request(self, request):
request.collector = collector(self, request, env)
request.channel.set_terminator(None)
else:
sin = StringIO.StringIO('')
sin = StringIO('')
self.continue_request(sin, request, env)

def continue_request(self, stdin, request, env):
Expand Down Expand Up @@ -279,7 +281,7 @@ def __init__(self, handler, request, env):
self.handler = handler
self.env = env
self.request = request
self.data = StringIO.StringIO()
self.data = StringIO()

# make sure there's a content-length header
self.cl = request.get_header('content-length')
Expand Down
Loading

0 comments on commit 967ff35

Please sign in to comment.