Commit 2b890915 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: modernize -f imports_six.

parent 461d7f48
from urlparse import urlparse
from urlparse import parse_qsl
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import parse_qsl
context.REQUEST.RESPONSE.setCookie("loyalty_reward", "disable", path='/')
......
from urlparse import urlparse
from urlparse import parse_qsl
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import parse_qsl
context.REQUEST.RESPONSE.setCookie("loyalty_reward", "enable", path='/')
......
......@@ -150,7 +150,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
return []
def cached_getTargetFormatItemList(content_type):
from xmlrpclib import Fault
from six.moves.xmlrpc_client import Fault
server_proxy = DocumentConversionServerProxy(self)
try:
allowed_target_item_list = server_proxy.getAllowedTargetItemList(
......
......@@ -26,7 +26,7 @@
#
##############################################################################
import urllib2
import six.moves.urllib.request
from lxml import etree
from erp5.component.document.Document import ConversionError
import base64
......@@ -36,7 +36,7 @@ SVG_DEFAULT_NAMESPACE = "http://www.w3.org/2000/svg"
def getDataURI(url):
try:
data = urllib2.urlopen(url)
data = six.moves.urllib.request.urlopen(url)
except Exception as e:
raise ConversionError("Error to transform url (%s) into data uri. ERROR = %s" % (url, Exception(e)))
return 'data:%s;base64,%s' % (data.info()["content-type"],
......
......@@ -6,7 +6,7 @@ from six.moves import cStringIO as StringIO
from erp5.portal_type import Image
from types import ModuleType
from ZODB.serialize import ObjectWriter
import cPickle
import six.moves.cPickle
import sys
import traceback
import ast
......@@ -589,7 +589,7 @@ def canSerialize(obj):
# for example: if the user defines a dict with an object of a class
# that he created the dump will stil work, but the load will fail.
try:
cPickle.loads(cPickle.dumps(obj))
six.moves.cPickle.loads(six.moves.cPickle.dumps(obj))
# By unknowing reasons, trying to catch cPickle.PicklingError in the "normal"
# way isn't working. This issue might be related to some weirdness in
# pickle/cPickle that is reported in this issue: http://bugs.python.org/issue1457119.
......@@ -599,7 +599,7 @@ def canSerialize(obj):
#
# Even though the issue seems complicated, this quickfix should be
# properly rewritten in a better way as soon as possible.
except (cPickle.PicklingError, TypeError, NameError, AttributeError):
except (six.moves.cPickle.PicklingError, TypeError, NameError, AttributeError):
return False
else:
return True
......
......@@ -28,7 +28,7 @@
##############################################################################
from Products.ERP5Form.FormBox import FormBox
from urlparse import urlparse
from six.moves.urllib.parse import urlparse
def Base_updatePropertyMapListWithFieldLabel(self, property_map_list):
"""Try to get the title of field which edit the given inside property_map_list
......
......@@ -26,6 +26,8 @@
##############################################################################
import re
def getLastWorkflowDate(self, state_name='simulation_state', state=('released','public')):
'''we can make something more generic out of it
or JP says "there is an API for it" and we trash this one'''
......
from erp5.component.document.Document import ConversionError
from erp5.component.module.Log import log
from ZODB.POSException import ConflictError
from xmlrpclib import Fault
from six.moves.xmlrpc_client import Fault
from socket import error as SocketError
message = None
......
......@@ -28,7 +28,7 @@ try:
except ImportError: # BBB Zope2
from Globals import package_home
import PIL.Image as PIL_Image
import thread
import six.moves._thread
import random
import base64
from OFS.Folder import Folder
......
......@@ -25,7 +25,7 @@
#
##############################################################################
from HTMLParser import HTMLParser
from six.moves.html_parser import HTMLParser
class HtmlParseHelper(HTMLParser):
"""
Listens to all the HTMLParser methods and push results in a list of tuple.
......
import json
import re
from urlparse import urljoin
from six.moves.urllib.parse import urljoin
if REQUEST is None:
REQUEST = context.REQUEST
......
......@@ -27,7 +27,7 @@
##############################################################################
import hashlib, httplib
import hashlib, six.moves.http_client
from Products.ERP5Type.UnrestrictedMethod import super_user
......@@ -110,6 +110,6 @@ def WebSite_viewAsWebPost(self, *args, **kwargs):
# security check should be done already.
document.publish()
self.REQUEST.RESPONSE.setStatus(httplib.CREATED)
self.REQUEST.RESPONSE.setStatus(six.moves.http_client.CREATED)
return sha512sum
......@@ -4,7 +4,7 @@ from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from zLOG import LOG, WARNING
import random, string, hashlib, urllib2, socket
from urlparse import urlparse
from six.moves.urllib.parse import urlparse
from six import string_types as basestring
try:
import xml.etree.cElementTree as ET
......
input_file = open('big_file.log', 'r')
import httplib
connection = httplib.HTTPConnection('192.168.242.68:12001')
import six.moves.http_client
connection = six.moves.http_client.HTTPConnection('192.168.242.68:12001')
import base64
base64string = base64.encodestring('zope:insecure')[:-1]
......
......@@ -67,4 +67,5 @@ def initialize( context ):
# allow import of various exceptions in restricted environment
# so we can catch them in ZODB scripts and inform user nicely
allow_module('xmlrpclib.Fault')
allow_module('six.moves.xmlrpc_client')
allow_module('socket.error')
import sys
import httplib
import six.moves.http_client
if ( len(sys.argv) != 5 ):
print("usage tinyWebClient.py host port method path")
......@@ -11,6 +11,6 @@ else:
info = (host, port)
print("%s:%s" % info)
conn = httplib.HTTPConnection("%s:%s" % info)
conn = six.moves.http_client.HTTPConnection("%s:%s" % info)
conn.request(method, path)
print(conn.getresponse().msg)
......@@ -18,15 +18,15 @@
# cgi-bin directory serves Python CGIs.
from __future__ import print_function
import BaseHTTPServer
import CGIHTTPServer
import six.moves.BaseHTTPServer
import six.moves.CGIHTTPServer
import time
import httplib
import six.moves.http_client
import sys
PORT = 8000
class HTTPHandler(CGIHTTPServer.CGIHTTPRequestHandler):
class HTTPHandler(six.moves.CGIHTTPServer.CGIHTTPRequestHandler):
"""
Simple Web Server that can handle query strings in a request URL and
can be stopped with a request
......@@ -48,7 +48,7 @@ class HTTPHandler(CGIHTTPServer.CGIHTTPRequestHandler):
time.sleep(0.3)
# Carry on with the rest of the processing...
CGIHTTPServer.CGIHTTPRequestHandler.do_GET(self)
six.moves.CGIHTTPServer.CGIHTTPRequestHandler.do_GET(self)
def do_QUIT(self):
self.send_response(200)
......@@ -61,7 +61,7 @@ if __name__ == '__main__':
port = int(sys.argv[1])
server_address = ('', port)
httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler)
httpd = six.moves.BaseHTTPServer.HTTPServer(server_address, HTTPHandler)
print("serving at port", port)
print("To run the entire JsUnit test suite, open")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment