diff --git a/demo/AUI_DockingWindowMgr.py b/demo/AUI_DockingWindowMgr.py index 2a82b83c..c177bd3f 100644 --- a/demo/AUI_DockingWindowMgr.py +++ b/demo/AUI_DockingWindowMgr.py @@ -9,7 +9,7 @@ try: except ImportError: # if it's not there locally, try the wxPython lib. import wx.lib.agw.aui as aui -from wx.lib.six import BytesIO +from six import BytesIO ID_CreateTree = wx.NewId() ID_CreateGrid = wx.NewId() diff --git a/demo/ArtProvider.py b/demo/ArtProvider.py index ae1a7be3..8e5f7f7e 100644 --- a/demo/ArtProvider.py +++ b/demo/ArtProvider.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Tags: phoenix-port, py3-port -from wx.lib.six import BytesIO +from six import BytesIO import wx @@ -287,7 +287,7 @@ def makeBitmap(data): back_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x07YID\ ATx\x9c\xa5\x97Ml\x9dG\x15\x86\x9fsf\xbe\xef^\xfb:\xaeS\xd7\xa9\x1d;!IK)\xfd\ A\x05\x95BQ\xc5\xdf\x02\xb1(\x12\x0b\x10\x8b\x8a\x05]Vl\xd8\xb2`\xcb\x92\xee\ @@ -364,7 +364,7 @@ b\xba!\x18G\x97\xe6\xf9\xc1\xb7\x97\xf9\x1f\x92tznH\x8fy\x14\x00\x00\x00\x00\ IEND\xaeB`\x82' down_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x042ID\ ATx\x9c\xa5\xd5Ko\x1bU\x14\xc0\xf1\xff\x8c\xe7\xe1g\xe2\xa6\x84\xa8\xa8\x82\ \xd0\x88E\xabJ\x08\t\x8a*\xb1@\x02v\xec@l`\x87\xf8\x1e\x91\xf8\x06 \x90\xd8\ @@ -410,7 +410,7 @@ s@\x84>\xde\xa0\xbf\x10GE\x98?~z\xc9Xv\xb6;k\x9b\xd8\xeb[K\xe1eKs\xda\xe9\ \xf9\x90\x00\x00\x00\x00IEND\xaeB`\x82' left_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\ \x03IDATx\x9c\xc5\xd7Mo\x1bE\x18\xc0\xf1\xff\xbe\xc4^\x9b\x86V\x81\x86\xf2\ \x8e\x8aJ+\x90(jE\x85\x84\xd4\x03\x12G$\xee\\\xb8\xf2-\xfa9\x10_\x82\x0b\x07\ @@ -455,7 +455,7 @@ Zl?^c\xb1\\\xe4\xc2\xd9\x0f\xb9\xf2\xf9\'\\xw\x96R\xe83[\xf0\xf8\xe9\xfb\xcb\ \x14\xff\x03\xe8\x84\x1b+\xdf\xf26\x9e\x00\x00\x00\x00IEND\xaeB`\x82' right_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\nI\ DATx\x9c\xc5\x96Ko\x1bU\x14\xc7\x7f\xf3\xb4=&\xd4mQ_H\xd0"\xdaD,\xda\x8aR\nB\ \xa8\xb0a\x83\xc4\x82\r{>\x01_\x00\xa9;>\x04\x0b\xb6,\xd9\xb0fQ@\x08\x81BU\ @@ -501,7 +501,7 @@ s\xaa\xf9\xdd\x1e\xb9d&\xbcf)\x928\xa1\xb5\xb9E\xbb\xbdA\x18\xf4&\xfa|\x16\ \x07\x8a\xed\x03}\xa8\xdcA9\x00\x00\x00\x00IEND\xaeB`\x82' smile16_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ \x00\x02\xa3IDATx\x9ce\x93\xdfkSg\x18\xc7?\xe7WL\x1b\xa2\x07!U\xa9\x89\xe9j\ \x90H\x87\x0cA\x86"\xb2\xf6B\xa1\xe0\x8d\xca\x19.\x88XJ\xa0\xb7R\xbc\x14\xbc\ @@ -532,7 +532,7 @@ smile16_png = \ \xf3\x07\xc0b=\xfa\xc1x\xb5\x84\x00\x00\x00\x00IEND\xaeB`\x82' smile32_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\t\xc0I\ DATx\x9c\xc5\x97il\\\xd5\x15\xc7\x7fo\xde\xbc7\xfbx6\xdb\x93L\xe2\x988\x9b\ \x81\x10H\xd8\n\xa8-\x90PJ\xcb\xee\x90\xb0\x94B(\x08\xa9\xad\xa0\x85\x82J\ @@ -634,7 +634,7 @@ J\xac\xae\xae\xea\x06\ cross_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x03\ \x9fIDATx\x9c\xc5\x97OH*_\x14\xc7\xbfW~\x82\x8c\x19Sh\xc2\x80\x8b\xfe\x10\ \x04A\x90P.\x84(r\x13ER\x14\x11\x18A\x11\x14\xba0\n\x83B\xa1\x90\\\x88\xa5\ diff --git a/demo/CustomDragAndDrop.py b/demo/CustomDragAndDrop.py index b638ef7f..7f1d5d1a 100644 --- a/demo/CustomDragAndDrop.py +++ b/demo/CustomDragAndDrop.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from wx.lib.six.moves import cPickle +from six.moves import cPickle import wx #---------------------------------------------------------------------- diff --git a/demo/ImageFromStream.py b/demo/ImageFromStream.py index a95f802d..091bf1cf 100644 --- a/demo/ImageFromStream.py +++ b/demo/ImageFromStream.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Tags: phoenix-port, py3-port -from wx.lib.six import BytesIO +from six import BytesIO import wx diff --git a/demo/KeyEvents.py b/demo/KeyEvents.py index 71c11fdb..a434e14a 100644 --- a/demo/KeyEvents.py +++ b/demo/KeyEvents.py @@ -2,7 +2,7 @@ import wx import wx.lib.mixins.listctrl as listmix -from wx.lib.six import unichr +from six import unichr #---------------------------------------------------------------------- diff --git a/demo/Main.py b/demo/Main.py index e422c475..1373eaaa 100644 --- a/demo/Main.py +++ b/demo/Main.py @@ -67,10 +67,10 @@ from wx.adv import TaskBarIcon as TaskBarIcon from wx.adv import SplashScreen as SplashScreen import wx.lib.mixins.inspection -import wx.lib.six as six -from wx.lib.six import exec_, BytesIO -from wx.lib.six.moves import cPickle -from wx.lib.six.moves import urllib +import six +from six import exec_, BytesIO +from six.moves import cPickle +from six.moves import urllib import version diff --git a/demo/MimeTypesManager.py b/demo/MimeTypesManager.py index ae1c2fdd..ffb48477 100644 --- a/demo/MimeTypesManager.py +++ b/demo/MimeTypesManager.py @@ -20,7 +20,7 @@ import images # helper function to make sure we don't convert unicode objects to strings # or vice versa when converting lists and None values to text. -import wx.lib.six as six +import six convert = six.text_type #---------------------------------------------------------------------------- diff --git a/demo/PropertyGrid.py b/demo/PropertyGrid.py index 57e0c750..ac29983b 100644 --- a/demo/PropertyGrid.py +++ b/demo/PropertyGrid.py @@ -7,7 +7,7 @@ import os import os.path import wx -from wx.lib.six import exec_ +from six import exec_ _ = wx.GetTranslation import wx.propgrid as wxpg diff --git a/demo/RichTextCtrl.py b/demo/RichTextCtrl.py index 440ef706..6c72586f 100644 --- a/demo/RichTextCtrl.py +++ b/demo/RichTextCtrl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from wx.lib.six import BytesIO +from six import BytesIO import wx import wx.richtext as rt diff --git a/demo/agw/FoldPanelBar.py b/demo/agw/FoldPanelBar.py index 53d11162..ea76b47b 100644 --- a/demo/agw/FoldPanelBar.py +++ b/demo/agw/FoldPanelBar.py @@ -6,7 +6,7 @@ import wx.adv import os import sys -from wx.lib.six import BytesIO +from six import BytesIO try: dirName = os.path.dirname(os.path.abspath(__file__)) diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index 6c161b83..17de60ff 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -11,7 +11,7 @@ import wx.lib.colourutils as cutils import sys -from wx.lib.six import BytesIO +from six import BytesIO try: dirName = os.path.dirname(os.path.abspath(__file__)) diff --git a/demo/agw/ListCtrl.py b/demo/agw/ListCtrl.py index 83d8da9d..699517c6 100644 --- a/demo/agw/ListCtrl.py +++ b/demo/agw/ListCtrl.py @@ -12,7 +12,7 @@ # Tags: phoenix-port, py3-port #---------------------------------------------------------------------------- -import wx.lib.six as six +import six import wx import wx.lib.mixins.listctrl as listmix diff --git a/demo/agw/Windows7Explorer_Contents.py b/demo/agw/Windows7Explorer_Contents.py index e742e113..f754d787 100644 --- a/demo/agw/Windows7Explorer_Contents.py +++ b/demo/agw/Windows7Explorer_Contents.py @@ -3,7 +3,7 @@ import sys import os import wx -import wx.lib.six as six +import six import time import datetime import operator diff --git a/etg/listctrl.py b/etg/listctrl.py index 6607679d..56ca5f8b 100644 --- a/etg/listctrl.py +++ b/etg/listctrl.py @@ -302,7 +302,7 @@ def run(): sequence with an item for each column''', body="""\ if len(entry): - from wx.lib.six import text_type + from six import text_type pos = self.GetItemCount() self.InsertItem(pos, text_type(entry[0])) for i in range(1, len(entry)): diff --git a/etg/wxdatetime.py b/etg/wxdatetime.py index 90f7e4b8..e4286938 100644 --- a/etg/wxdatetime.py +++ b/etg/wxdatetime.py @@ -253,7 +253,7 @@ def run(): c.addPyMethod('__repr__', '(self)', """\ - from wx.lib.six import PY2 + from six import PY2 if self.IsValid(): f = self.Format() if PY2: f = f.encode('utf-8') @@ -263,7 +263,7 @@ def run(): """) c.addPyMethod('__str__', '(self)', """\ - from wx.lib.six import PY2 + from six import PY2 if self.IsValid(): f = self.Format() if PY2: f = f.encode('utf-8') diff --git a/samples/printing/printing.py b/samples/printing/printing.py index 0a3bd000..c0018653 100644 --- a/samples/printing/printing.py +++ b/samples/printing/printing.py @@ -1,5 +1,5 @@ import wx -from wx.lib.six import print_ +from six import print_ import os FONTSIZE = 10 diff --git a/samples/roses/clroses.py b/samples/roses/clroses.py index c5c6329c..51ba2947 100644 --- a/samples/roses/clroses.py +++ b/samples/roses/clroses.py @@ -37,7 +37,7 @@ # independence, override defaults, ignore features, etc. from math import sin, cos, pi -from wx.lib.six import print_ +from six import print_ # Rose class knows about: # > Generating points and vectors (returning data as a list of points) diff --git a/samples/roses/wxroses.py b/samples/roses/wxroses.py index d09b2529..7bfbdea5 100644 --- a/samples/roses/wxroses.py +++ b/samples/roses/wxroses.py @@ -71,7 +71,7 @@ import wx import clroses import wx.lib.colourselect as cs -from wx.lib.six import print_ +from six import print_ # Class SpinPanel creates a control that includes both a StaticText widget # which holds the the name of a parameter and a SpinCtrl widget which diff --git a/samples/simple/events.py b/samples/simple/events.py index f7b49226..2cba3f4d 100644 --- a/samples/simple/events.py +++ b/samples/simple/events.py @@ -1,6 +1,6 @@ import wx -from wx.lib.six import print_ +from six import print_ print_(wx.version()) #import os; print_('PID:', os.getpid()); raw_input('Ready to start, press enter...') diff --git a/setup.py b/setup.py index d4b9172d..82a416a2 100644 --- a/setup.py +++ b/setup.py @@ -12,11 +12,10 @@ import sys, os import glob -from setuptools import setup, Extension, find_packages +from setuptools import setup, find_packages from distutils.command.build import build as orig_build from setuptools.command.install import install as orig_install from setuptools.command.bdist_egg import bdist_egg as orig_bdist_egg -from setuptools.command.build_py import build_py as orig_build_py from setuptools.command.sdist import sdist as orig_sdist try: from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel @@ -68,6 +67,8 @@ Programming Language :: Python :: 3.5 Topic :: Software Development :: User Interfaces """ +DEPENDENCIES = [ 'six', + ] isWindows = sys.platform.startswith('win') isDarwin = sys.platform == "darwin" @@ -333,6 +334,7 @@ if __name__ == '__main__': platforms = PLATFORMS, classifiers = [c for c in CLASSIFIERS.split("\n") if c], keywords = KEYWORDS, + install_requires = DEPENDENCIES, zip_safe = False, use_2to3 = False, include_package_data = True, diff --git a/sphinxtools/modulehunter.py b/sphinxtools/modulehunter.py index 0881fac1..f484ec1f 100644 --- a/sphinxtools/modulehunter.py +++ b/sphinxtools/modulehunter.py @@ -346,7 +346,7 @@ def describe_class(obj, module_class, module_name, constants): # Thanks to ReportLab for this funny exception... continue except ImportError: - # This can come from the pseudo module in wx.lib.six + # This can come from the pseudo module in six message = "ImportError from '%s.%s'.\n Exception was: %s"%(obj, name, format_traceback()) print(('\nWARNING: %s\n' % message)) continue diff --git a/unittests/do-runtests.py b/unittests/do-runtests.py index 4b7aa98f..0f3adec1 100644 --- a/unittests/do-runtests.py +++ b/unittests/do-runtests.py @@ -17,7 +17,7 @@ and also for the code that calls this script via subprocess. import sys import os import unittest -import wx.lib.six as six +import six import pickle g_testResult = None diff --git a/unittests/runtests.py b/unittests/runtests.py index 5ee4f77c..6d18ed11 100755 --- a/unittests/runtests.py +++ b/unittests/runtests.py @@ -39,7 +39,7 @@ else: # run as main? sys.path.insert(0, phoenixDir) import wx -import wx.lib.six as six +import six print("wx.version: " + wx.version()) print("pid: " + str(os.getpid())) #print("executable: " + sys.executable); raw_input("Press Enter...") diff --git a/unittests/test_arraystring.py b/unittests/test_arraystring.py index e1bd891a..53727b17 100644 --- a/unittests/test_arraystring.py +++ b/unittests/test_arraystring.py @@ -2,7 +2,7 @@ import unittest import wx import wtc import sys -import wx.lib.six as six +import six #--------------------------------------------------------------------------- diff --git a/unittests/test_bitmap.py b/unittests/test_bitmap.py index 52693118..5dc55464 100644 --- a/unittests/test_bitmap.py +++ b/unittests/test_bitmap.py @@ -2,7 +2,7 @@ import unittest import wtc import wx import os -import wx.lib.six as six +import six pngFile = os.path.join(os.path.dirname(__file__), 'toucan.png') diff --git a/unittests/test_cmndata.py b/unittests/test_cmndata.py index 9ce2d8c7..29e8f7c4 100644 --- a/unittests/test_cmndata.py +++ b/unittests/test_cmndata.py @@ -1,7 +1,7 @@ import unittest import wtc import wx -import wx.lib.six as six +import six #--------------------------------------------------------------------------- diff --git a/unittests/test_cursor.py b/unittests/test_cursor.py index 5aa4184e..3b80510b 100644 --- a/unittests/test_cursor.py +++ b/unittests/test_cursor.py @@ -1,7 +1,7 @@ import unittest import wtc import wx -import wx.lib.six as six +import six import os pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png') diff --git a/unittests/test_image.py b/unittests/test_image.py index 3e6710ff..10fce8bf 100644 --- a/unittests/test_image.py +++ b/unittests/test_image.py @@ -1,8 +1,8 @@ import unittest import wtc import wx -import wx.lib.six as six -from wx.lib.six import BytesIO as FileLikeObject +import six +from six import BytesIO as FileLikeObject import os @@ -136,9 +136,9 @@ class image_Tests(wtc.WidgetTestCase): self.assertTrue(img.IsOk()) data = img.GetDataBuffer() self.assertTrue(isinstance(data, memoryview)) - data[0] = 1 if six.PY33 else b'\1' - data[1] = 2 if six.PY33 else b'\2' - data[2] = 3 if six.PY33 else b'\3' + data[0] = 1 + data[1] = 2 + data[2] = 3 self.assertEqual(1, img.GetRed(0,0)) self.assertEqual(2, img.GetGreen(0,0)) self.assertEqual(3, img.GetBlue(0,0)) @@ -150,9 +150,9 @@ class image_Tests(wtc.WidgetTestCase): self.assertTrue(img.IsOk()) data = img.GetAlphaBuffer() self.assertTrue(isinstance(data, memoryview)) - data[0] = 1 if six.PY33 else b'\1' - data[1] = 2 if six.PY33 else b'\2' - data[2] = 3 if six.PY33 else b'\3' + data[0] = 1 + data[1] = 2 + data[2] = 3 self.assertEqual(1, img.GetAlpha(0,0)) self.assertEqual(2, img.GetAlpha(1,0)) self.assertEqual(3, img.GetAlpha(2,0)) diff --git a/unittests/test_lib_cdate.py b/unittests/test_lib_cdate.py index e7022994..9f49e726 100644 --- a/unittests/test_lib_cdate.py +++ b/unittests/test_lib_cdate.py @@ -1,7 +1,7 @@ import unittest import wtc import wx.lib.CDate as cdate -import wx.lib.six as six +import six class lib_cdate_Tests(wtc.WidgetTestCase): diff --git a/unittests/test_lib_pubsub_defaultlog.py b/unittests/test_lib_pubsub_defaultlog.py index 04eddfd3..f9683e42 100644 --- a/unittests/test_lib_pubsub_defaultlog.py +++ b/unittests/test_lib_pubsub_defaultlog.py @@ -10,7 +10,7 @@ import unittest import wtc from wx.lib.pubsub.utils import notification -from wx.lib.six import StringIO +from six import StringIO #--------------------------------------------------------------------------- diff --git a/unittests/test_lib_pubsub_notify.py b/unittests/test_lib_pubsub_notify.py index ced06a04..ca3a1670 100644 --- a/unittests/test_lib_pubsub_notify.py +++ b/unittests/test_lib_pubsub_notify.py @@ -22,7 +22,7 @@ class lib_pubsub_Notify(wtc.PubsubTestCase): from wx.lib.pubsub.utils.notification import useNotifyByWriteFile def captureStdout(): - from wx.lib.six import StringIO + from six import StringIO capture = StringIO() useNotifyByWriteFile( fileObj = capture ) return capture diff --git a/unittests/test_lib_pubsub_notify4.py b/unittests/test_lib_pubsub_notify4.py index 153a762d..60640255 100644 --- a/unittests/test_lib_pubsub_notify4.py +++ b/unittests/test_lib_pubsub_notify4.py @@ -9,7 +9,7 @@ import unittest import wtc -import wx.lib.six as six +import six from difflib import ndiff, unified_diff, context_diff diff --git a/unittests/test_lib_pubsub_topicmgr.py b/unittests/test_lib_pubsub_topicmgr.py index 8306400a..b23ba7af 100644 --- a/unittests/test_lib_pubsub_topicmgr.py +++ b/unittests/test_lib_pubsub_topicmgr.py @@ -359,7 +359,7 @@ class lib_pubsub_TopicMgr3_TreeTraverser(wtc.PubsubTestCase): topicMgr.getOrCreateTopic('a2.b.a') topicMgr.getOrCreateTopic('a2.b.b') - from wx.lib.six import StringIO + from six import StringIO buffer = StringIO() printTreeDocs(rootTopic=root, width=70, fileObj=buffer) self.assertEqual( buffer.getvalue(), self.expectedOutput ) diff --git a/unittests/test_stream.py b/unittests/test_stream.py index fb1ec58d..d4e3416f 100644 --- a/unittests/test_stream.py +++ b/unittests/test_stream.py @@ -1,8 +1,8 @@ import unittest import wtc import wx -import wx.lib.six as six -from wx.lib.six import BytesIO as FileLikeObject +import six +from six import BytesIO as FileLikeObject import os diff --git a/unittests/test_string.py b/unittests/test_string.py index 8fc9483e..26cdb7b6 100644 --- a/unittests/test_string.py +++ b/unittests/test_string.py @@ -1,6 +1,6 @@ import unittest import wx -import wx.lib.six as six +import six import wtc #--------------------------------------------------------------------------- diff --git a/unittests/test_variant.py b/unittests/test_variant.py index a8fff102..fda51b9c 100644 --- a/unittests/test_variant.py +++ b/unittests/test_variant.py @@ -2,7 +2,7 @@ import unittest import wtc import wx -import wx.lib.six as six +import six #--------------------------------------------------------------------------- diff --git a/unittests/test_window.py b/unittests/test_window.py index 4898b11a..6f063539 100644 --- a/unittests/test_window.py +++ b/unittests/test_window.py @@ -1,7 +1,7 @@ import unittest import wtc import wx -import wx.lib.six as six +import six #--------------------------------------------------------------------------- diff --git a/unittests/test_wxdatetime.py b/unittests/test_wxdatetime.py index 4ab618e8..34b03da7 100644 --- a/unittests/test_wxdatetime.py +++ b/unittests/test_wxdatetime.py @@ -1,6 +1,6 @@ import unittest import wx -import wx.lib.six as six +import six import wtc import datetime import time diff --git a/unittests/wtc.py b/unittests/wtc.py index 8fe04458..d6873af3 100644 --- a/unittests/wtc.py +++ b/unittests/wtc.py @@ -1,7 +1,7 @@ import unittest import wx import sys, os -import wx.lib.six as six +import six #--------------------------------------------------------------------------- diff --git a/wx/lib/agw/artmanager.py b/wx/lib/agw/artmanager.py index e56a9eb9..5a53f2a2 100644 --- a/wx/lib/agw/artmanager.py +++ b/wx/lib/agw/artmanager.py @@ -6,7 +6,7 @@ This module contains drawing routines and customizations for the AGW widgets import wx import random -from wx.lib.six import BytesIO +from six import BytesIO from .fmresources import * diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index 8743363f..137d21b8 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -30,7 +30,7 @@ import wx from .aui_utilities import BitmapFromBits, StepColour, GetLabelSize from .aui_utilities import GetBaseColour, MakeDisabledBitmap -import wx.lib.six as six +import six from .aui_constants import * diff --git a/wx/lib/agw/aui/auibook.py b/wx/lib/agw/aui/auibook.py index 9f9c2571..4120f69e 100644 --- a/wx/lib/agw/aui/auibook.py +++ b/wx/lib/agw/aui/auibook.py @@ -32,7 +32,7 @@ import wx import datetime from wx.lib.expando import ExpandoTextCtrl -import wx.lib.six as six +import six from . import tabart as TA diff --git a/wx/lib/agw/aui/framemanager.py b/wx/lib/agw/aui/framemanager.py index 6e53b1e2..67d5040d 100644 --- a/wx/lib/agw/aui/framemanager.py +++ b/wx/lib/agw/aui/framemanager.py @@ -102,7 +102,7 @@ import wx.lib.sized_controls as sc import time import warnings -import wx.lib.six as six +import six from . import auibar from . import auibook diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 71bc6a9d..d609266c 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -312,7 +312,7 @@ import wx from wx.lib.expando import ExpandoTextCtrl # Python 2/3 compatibility helper -import wx.lib.six as six +import six # ---------------------------------------------------------------------------- # Constants diff --git a/wx/lib/agw/flatmenu.py b/wx/lib/agw/flatmenu.py index dd925fb8..f10a8c02 100644 --- a/wx/lib/agw/flatmenu.py +++ b/wx/lib/agw/flatmenu.py @@ -200,7 +200,7 @@ import math import wx.lib.colourutils as colourutils -import wx.lib.six as six +import six from .fmcustomizedlg import FMCustomizeDlg from .artmanager import ArtManager, DCSaver diff --git a/wx/lib/agw/flatnotebook.py b/wx/lib/agw/flatnotebook.py index 092a9027..ea305dbd 100644 --- a/wx/lib/agw/flatnotebook.py +++ b/wx/lib/agw/flatnotebook.py @@ -192,7 +192,7 @@ import math import weakref import pickle -import wx.lib.six as six +import six # Used on OSX to get access to carbon api constants if wx.Platform == '__WXMAC__': diff --git a/wx/lib/agw/floatspin.py b/wx/lib/agw/floatspin.py index ca1a257c..7b623ad1 100644 --- a/wx/lib/agw/floatspin.py +++ b/wx/lib/agw/floatspin.py @@ -178,7 +178,7 @@ import locale from math import ceil, floor # Python 2/3 compatibility helper -import wx.lib.six as six +import six if six.PY3: long = int diff --git a/wx/lib/agw/fmcustomizedlg.py b/wx/lib/agw/fmcustomizedlg.py index 31604dce..426c2eab 100644 --- a/wx/lib/agw/fmcustomizedlg.py +++ b/wx/lib/agw/fmcustomizedlg.py @@ -16,7 +16,7 @@ This module contains a custom dialog class used to personalize the appearance of """ import wx -import wx.lib.six as six +import six if six.PY2: from UserDict import UserDict diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index b5dd99b2..0f1146d2 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -278,7 +278,7 @@ from wx.lib.agw.customtreectrl import TreeEditTimer as TreeListEditTimer from wx.lib.agw.customtreectrl import EVT_TREE_ITEM_CHECKING, EVT_TREE_ITEM_CHECKED, EVT_TREE_ITEM_HYPERLINK # Python 2/3 compatibility helper -import wx.lib.six as six +import six # Version Info __version__ = "1.4" diff --git a/wx/lib/agw/persist/persist_constants.py b/wx/lib/agw/persist/persist_constants.py index ca6ce67a..e94e4b58 100644 --- a/wx/lib/agw/persist/persist_constants.py +++ b/wx/lib/agw/persist/persist_constants.py @@ -12,7 +12,7 @@ This module contains all the constants used by the persistent objects. import wx import wx.dataview as dv -import wx.lib.six as six +import six # ----------------------------------------------------------------------------------- # # PersistenceManager styles diff --git a/wx/lib/agw/ribbon/bar.py b/wx/lib/agw/ribbon/bar.py index 4ca375ab..6454a3c9 100644 --- a/wx/lib/agw/ribbon/bar.py +++ b/wx/lib/agw/ribbon/bar.py @@ -97,7 +97,7 @@ See Also import wx -import wx.lib.six as six +import six from .control import RibbonControl diff --git a/wx/lib/agw/ribbon/buttonbar.py b/wx/lib/agw/ribbon/buttonbar.py index 3f9c31c8..cde9b8bf 100644 --- a/wx/lib/agw/ribbon/buttonbar.py +++ b/wx/lib/agw/ribbon/buttonbar.py @@ -46,7 +46,7 @@ Event Name Description import wx -import wx.lib.six as six +import six from .control import RibbonControl from .art import * diff --git a/wx/lib/agw/rulerctrl.py b/wx/lib/agw/rulerctrl.py index c032baea..488ab9df 100644 --- a/wx/lib/agw/rulerctrl.py +++ b/wx/lib/agw/rulerctrl.py @@ -167,7 +167,7 @@ except: pass # Python 2/3 compatibility helper -import wx.lib.six as six +import six # Built-in formats IntFormat = 1 diff --git a/wx/lib/agw/thumbnailctrl.py b/wx/lib/agw/thumbnailctrl.py index 0509d88c..9574f443 100644 --- a/wx/lib/agw/thumbnailctrl.py +++ b/wx/lib/agw/thumbnailctrl.py @@ -166,7 +166,7 @@ import os import time import zlib -import wx.lib.six as six +import six from math import pi from wx.lib.embeddedimage import PyEmbeddedImage diff --git a/wx/lib/agw/ultimatelistctrl.py b/wx/lib/agw/ultimatelistctrl.py index c3de37b2..531c942a 100644 --- a/wx/lib/agw/ultimatelistctrl.py +++ b/wx/lib/agw/ultimatelistctrl.py @@ -237,7 +237,7 @@ import math import bisect import zlib -import wx.lib.six as six +import six from wx.lib.expando import ExpandoTextCtrl diff --git a/wx/lib/agw/xlsgrid.py b/wx/lib/agw/xlsgrid.py index 21f4a344..d55920ef 100644 --- a/wx/lib/agw/xlsgrid.py +++ b/wx/lib/agw/xlsgrid.py @@ -250,7 +250,7 @@ import string import wx.grid as gridlib -import wx.lib.six as six +import six from wx.lib.embeddedimage import PyEmbeddedImage from wx.lib.wordwrap import wordwrap diff --git a/wx/lib/agw/zoombar.py b/wx/lib/agw/zoombar.py index 425c2c1d..760340eb 100644 --- a/wx/lib/agw/zoombar.py +++ b/wx/lib/agw/zoombar.py @@ -133,7 +133,7 @@ Version 0.1 import wx import sys -import wx.lib.six as six +import six from wx.lib.embeddedimage import PyEmbeddedImage diff --git a/wx/lib/embeddedimage.py b/wx/lib/embeddedimage.py index 2d01dddc..e9b4970d 100644 --- a/wx/lib/embeddedimage.py +++ b/wx/lib/embeddedimage.py @@ -15,7 +15,7 @@ import base64 import wx -from wx.lib.six import BytesIO +from six import BytesIO try: b64decode = base64.b64decode diff --git a/wx/lib/fancytext.py b/wx/lib/fancytext.py index 2feb5f3c..93f75f7f 100644 --- a/wx/lib/fancytext.py +++ b/wx/lib/fancytext.py @@ -58,7 +58,7 @@ import math import sys import wx -import wx.lib.six as six +import six import xml.parsers.expat @@ -234,7 +234,7 @@ class Renderer: def renderCharacterData(self, data, x, y): raise NotImplementedError() -from wx.lib.six import PY3 +from six import PY3 def _addGreek(): alpha = 0xE1 diff --git a/wx/lib/floatcanvas/Resources.py b/wx/lib/floatcanvas/Resources.py index 60fa9aa1..7235c456 100644 --- a/wx/lib/floatcanvas/Resources.py +++ b/wx/lib/floatcanvas/Resources.py @@ -4,7 +4,7 @@ from wx import Image as ImageFromStream from wx import Bitmap as BitmapFromImage -from wx.lib.six import BytesIO +from six import BytesIO import zlib diff --git a/wx/lib/floatcanvas/ScreenShot.py b/wx/lib/floatcanvas/ScreenShot.py index abd59dac..52e9a699 100644 --- a/wx/lib/floatcanvas/ScreenShot.py +++ b/wx/lib/floatcanvas/ScreenShot.py @@ -4,7 +4,7 @@ from wx import Image as ImageFromStream from wx import BitmapFromImage -from wx.lib.six import BytesIO +from six import BytesIO import zlib diff --git a/wx/lib/inspection.py b/wx/lib/inspection.py index 20194129..b7d2e846 100644 --- a/wx/lib/inspection.py +++ b/wx/lib/inspection.py @@ -28,7 +28,7 @@ import wx.py import wx.stc #import wx.aui as aui import wx.lib.agw.aui as aui -import wx.lib.six as six +import six import wx.lib.utils as utils import sys import inspect diff --git a/wx/lib/intctrl.py b/wx/lib/intctrl.py index 8da7fa56..60ac70bd 100644 --- a/wx/lib/intctrl.py +++ b/wx/lib/intctrl.py @@ -41,7 +41,7 @@ import string import types import wx -import wx.lib.six as six +import six #---------------------------------------------------------------------------- diff --git a/wx/lib/masked/ipaddrctrl.py b/wx/lib/masked/ipaddrctrl.py index fce4adad..1b217775 100644 --- a/wx/lib/masked/ipaddrctrl.py +++ b/wx/lib/masked/ipaddrctrl.py @@ -23,7 +23,7 @@ user hits '.' when typing. """ import wx -import wx.lib.six as six +import six from wx.lib.masked import BaseMaskedTextCtrl # jmg 12/9/03 - when we cut ties with Py 2.2 and earlier, this would diff --git a/wx/lib/masked/maskededit.py b/wx/lib/masked/maskededit.py index ac7c6e71..d87769d3 100644 --- a/wx/lib/masked/maskededit.py +++ b/wx/lib/masked/maskededit.py @@ -813,7 +813,7 @@ import string import sys import wx -import wx.lib.six as six +import six # jmg 12/9/03 - when we cut ties with Py 2.2 and earlier, this would # be a good place to implement the 2.3 logger class diff --git a/wx/lib/masked/numctrl.py b/wx/lib/masked/numctrl.py index 5ffdabc2..8bc06b65 100644 --- a/wx/lib/masked/numctrl.py +++ b/wx/lib/masked/numctrl.py @@ -401,7 +401,7 @@ GetAutoSize() import copy import wx -import wx.lib.six as six +import six from sys import maxsize MAXINT = maxsize # (constants should be in upper case) diff --git a/wx/lib/masked/timectrl.py b/wx/lib/masked/timectrl.py index f2a4c964..7f15dacd 100644 --- a/wx/lib/masked/timectrl.py +++ b/wx/lib/masked/timectrl.py @@ -277,7 +277,7 @@ IsLimited() import copy import wx -import wx.lib.six as six +import six from wx.tools.dbg import Logger from wx.lib.masked import Field, BaseMaskedTextCtrl diff --git a/wx/lib/mixins/listctrl.py b/wx/lib/mixins/listctrl.py index 6007dd62..4f610e7d 100644 --- a/wx/lib/mixins/listctrl.py +++ b/wx/lib/mixins/listctrl.py @@ -33,7 +33,7 @@ import locale import wx -import wx.lib.six as six +import six if six.PY3: # python 3 lacks cmp: diff --git a/wx/lib/multisash.py b/wx/lib/multisash.py index 4ab26164..30da4f49 100644 --- a/wx/lib/multisash.py +++ b/wx/lib/multisash.py @@ -21,7 +21,7 @@ import wx -import wx.lib.six as six +import six MV_HOR = 0 MV_VER = not MV_HOR diff --git a/wx/lib/pdfviewer/viewer.py b/wx/lib/pdfviewer/viewer.py index de753db4..2e80d87b 100644 --- a/wx/lib/pdfviewer/viewer.py +++ b/wx/lib/pdfviewer/viewer.py @@ -29,8 +29,8 @@ import types import copy import shutil -import wx.lib.six as six -from wx.lib.six import BytesIO +import six +from six import BytesIO USE_CAIRO = True FONTSCALE = 1.0 diff --git a/wx/lib/rcsizer.py b/wx/lib/rcsizer.py index 6f9c5c2e..1ca9d390 100644 --- a/wx/lib/rcsizer.py +++ b/wx/lib/rcsizer.py @@ -33,7 +33,7 @@ encouraged to switch. import operator import wx -import wx.lib.six as six +import six if six.PY3: from functools import reduce as reduce diff --git a/wx/lib/six.py b/wx/lib/six.py deleted file mode 100644 index 156b7a34..00000000 --- a/wx/lib/six.py +++ /dev/null @@ -1,839 +0,0 @@ -"""Utilities for writing code that runs on Python 2 and 3""" - -# Copyright (c) 2010-2015 Benjamin Peterson -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import - -import functools -import itertools -import operator -import sys -import types - -__author__ = "Benjamin Peterson " -__version__ = "1.9.0" - - -# Useful for very coarse version differentiation. -PY2 = sys.version_info[0] == 2 -PY3 = sys.version_info[0] == 3 -PY33 = sys.version_info[0] == 3 and sys.version_info[1] >= 3 #*# wxPython change - -if PY3: - string_types = str, - integer_types = int, - class_types = type, - text_type = str - binary_type = bytes - - MAXSIZE = sys.maxsize -else: - string_types = basestring, - integer_types = (int, long) - class_types = (type, types.ClassType) - text_type = unicode - binary_type = str - - if sys.platform.startswith("java"): - # Jython always uses 32 bits. - MAXSIZE = int((1 << 31) - 1) - else: - # It's possible to have sizeof(long) != sizeof(Py_ssize_t). - class X(object): - def __len__(self): - return 1 << 31 - try: - len(X()) - except OverflowError: - # 32-bit - MAXSIZE = int((1 << 31) - 1) - else: - # 64-bit - MAXSIZE = int((1 << 63) - 1) - del X - - -def _add_doc(func, doc): - """Add documentation to a function.""" - func.__doc__ = doc - - -def _import_module(name): - """Import module, returning the module after the last dot.""" - __import__(name) - return sys.modules[name] - - -class _LazyDescr(object): - - def __init__(self, name): - self.name = name - - def __get__(self, obj, tp): - result = self._resolve() - setattr(obj, self.name, result) # Invokes __set__. - try: - # This is a bit ugly, but it avoids running this again by - # removing this descriptor. - delattr(obj.__class__, self.name) - except AttributeError: - pass - return result - - -class MovedModule(_LazyDescr): - - def __init__(self, name, old, new=None): - super(MovedModule, self).__init__(name) - if PY3: - if new is None: - new = name - self.mod = new - else: - self.mod = old - - def _resolve(self): - return _import_module(self.mod) - - def __getattr__(self, attr): - _module = self._resolve() - value = getattr(_module, attr) - setattr(self, attr, value) - return value - - -class _LazyModule(types.ModuleType): - - def __init__(self, name): - super(_LazyModule, self).__init__(name) - self.__doc__ = self.__class__.__doc__ - - def __dir__(self): - attrs = ["__doc__", "__name__"] - attrs += [attr.name for attr in self._moved_attributes] - return attrs - - # Subclasses should override this - _moved_attributes = [] - - -class MovedAttribute(_LazyDescr): - - def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): - super(MovedAttribute, self).__init__(name) - if PY3: - if new_mod is None: - new_mod = name - self.mod = new_mod - if new_attr is None: - if old_attr is None: - new_attr = name - else: - new_attr = old_attr - self.attr = new_attr - else: - self.mod = old_mod - if old_attr is None: - old_attr = name - self.attr = old_attr - - def _resolve(self): - module = _import_module(self.mod) - return getattr(module, self.attr) - - -class _SixMetaPathImporter(object): - """ - A meta path importer to import six.moves and its submodules. - - This class implements a PEP302 finder and loader. It should be compatible - with Python 2.5 and all existing versions of Python3 - """ - def __init__(self, six_module_name): - self.name = six_module_name - self.known_modules = {} - - def _add_module(self, mod, *fullnames): - for fullname in fullnames: - self.known_modules[self.name + "." + fullname] = mod - - def _get_module(self, fullname): - return self.known_modules[self.name + "." + fullname] - - def find_module(self, fullname, path=None): - if fullname in self.known_modules: - return self - return None - - def __get_module(self, fullname): - try: - return self.known_modules[fullname] - except KeyError: - raise ImportError("This loader does not know module " + fullname) - - def load_module(self, fullname): - try: - # in case of a reload - return sys.modules[fullname] - except KeyError: - pass - mod = self.__get_module(fullname) - if isinstance(mod, MovedModule): - mod = mod._resolve() - else: - mod.__loader__ = self - sys.modules[fullname] = mod - return mod - - def is_package(self, fullname): - """ - Return true, if the named module is a package. - - We need this method to get correct spec objects with - Python 3.4 (see PEP451) - """ - return hasattr(self.__get_module(fullname), "__path__") - - def get_code(self, fullname): - """Return None - - Required, if is_package is implemented""" - self.__get_module(fullname) # eventually raises ImportError - return None - get_source = get_code # same as get_code - -_importer = _SixMetaPathImporter(__name__) - - -class _MovedItems(_LazyModule): - """Lazy loading of moved objects""" - __path__ = [] # mark as package - - -_moved_attributes = [ - MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), - MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), - MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), - MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), - MovedAttribute("intern", "__builtin__", "sys"), - MovedAttribute("map", "itertools", "builtins", "imap", "map"), - MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("reload_module", "__builtin__", "imp", "reload"), - MovedAttribute("reduce", "__builtin__", "functools"), - MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), - MovedAttribute("StringIO", "StringIO", "io"), - MovedAttribute("UserDict", "UserDict", "collections"), - MovedAttribute("UserList", "UserList", "collections"), - MovedAttribute("UserString", "UserString", "collections"), - MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), - MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), - - MovedModule("builtins", "__builtin__"), - MovedModule("configparser", "ConfigParser"), - MovedModule("copyreg", "copy_reg"), - MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), - MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), - MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), - MovedModule("http_cookies", "Cookie", "http.cookies"), - MovedModule("html_entities", "htmlentitydefs", "html.entities"), - MovedModule("html_parser", "HTMLParser", "html.parser"), - MovedModule("http_client", "httplib", "http.client"), - MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), - MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), - MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), - MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), - MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), - MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), - MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), - MovedModule("cPickle", "cPickle", "pickle"), - MovedModule("queue", "Queue"), - MovedModule("reprlib", "repr"), - MovedModule("socketserver", "SocketServer"), - MovedModule("_thread", "thread", "_thread"), - MovedModule("tkinter", "Tkinter"), - MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), - MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), - MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), - MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), - MovedModule("tkinter_tix", "Tix", "tkinter.tix"), - MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), - MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), - MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), - MovedModule("tkinter_colorchooser", "tkColorChooser", - "tkinter.colorchooser"), - MovedModule("tkinter_commondialog", "tkCommonDialog", - "tkinter.commondialog"), - MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), - MovedModule("tkinter_font", "tkFont", "tkinter.font"), - MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), - MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", - "tkinter.simpledialog"), - MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), - MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), - MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), - MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), - MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), - MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), - MovedModule("winreg", "_winreg"), -] -for attr in _moved_attributes: - setattr(_MovedItems, attr.name, attr) - if isinstance(attr, MovedModule): - _importer._add_module(attr, "moves." + attr.name) -del attr - -_MovedItems._moved_attributes = _moved_attributes - -moves = _MovedItems(__name__ + ".moves") -_importer._add_module(moves, "moves") - - -class Module_six_moves_urllib_parse(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_parse""" - - -_urllib_parse_moved_attributes = [ - MovedAttribute("ParseResult", "urlparse", "urllib.parse"), - MovedAttribute("SplitResult", "urlparse", "urllib.parse"), - MovedAttribute("parse_qs", "urlparse", "urllib.parse"), - MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), - MovedAttribute("urldefrag", "urlparse", "urllib.parse"), - MovedAttribute("urljoin", "urlparse", "urllib.parse"), - MovedAttribute("urlparse", "urlparse", "urllib.parse"), - MovedAttribute("urlsplit", "urlparse", "urllib.parse"), - MovedAttribute("urlunparse", "urlparse", "urllib.parse"), - MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), - MovedAttribute("quote", "urllib", "urllib.parse"), - MovedAttribute("quote_plus", "urllib", "urllib.parse"), - MovedAttribute("unquote", "urllib", "urllib.parse"), - MovedAttribute("unquote_plus", "urllib", "urllib.parse"), - MovedAttribute("urlencode", "urllib", "urllib.parse"), - MovedAttribute("splitquery", "urllib", "urllib.parse"), - MovedAttribute("splittag", "urllib", "urllib.parse"), - MovedAttribute("splituser", "urllib", "urllib.parse"), - MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), - MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), - MovedAttribute("uses_params", "urlparse", "urllib.parse"), - MovedAttribute("uses_query", "urlparse", "urllib.parse"), - MovedAttribute("uses_relative", "urlparse", "urllib.parse"), -] -for attr in _urllib_parse_moved_attributes: - setattr(Module_six_moves_urllib_parse, attr.name, attr) -del attr - -Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes - -_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), - "moves.urllib_parse", "moves.urllib.parse") - - -class Module_six_moves_urllib_error(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_error""" - - -_urllib_error_moved_attributes = [ - MovedAttribute("URLError", "urllib2", "urllib.error"), - MovedAttribute("HTTPError", "urllib2", "urllib.error"), - MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), -] -for attr in _urllib_error_moved_attributes: - setattr(Module_six_moves_urllib_error, attr.name, attr) -del attr - -Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes - -_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), - "moves.urllib_error", "moves.urllib.error") - - -class Module_six_moves_urllib_request(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_request""" - - -_urllib_request_moved_attributes = [ - MovedAttribute("urlopen", "urllib2", "urllib.request"), - MovedAttribute("install_opener", "urllib2", "urllib.request"), - MovedAttribute("build_opener", "urllib2", "urllib.request"), - MovedAttribute("pathname2url", "urllib", "urllib.request"), - MovedAttribute("url2pathname", "urllib", "urllib.request"), - MovedAttribute("getproxies", "urllib", "urllib.request"), - MovedAttribute("Request", "urllib2", "urllib.request"), - MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), - MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), - MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), - MovedAttribute("BaseHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), - MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), - MovedAttribute("FileHandler", "urllib2", "urllib.request"), - MovedAttribute("FTPHandler", "urllib2", "urllib.request"), - MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), - MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), - MovedAttribute("urlretrieve", "urllib", "urllib.request"), - MovedAttribute("urlcleanup", "urllib", "urllib.request"), - MovedAttribute("URLopener", "urllib", "urllib.request"), - MovedAttribute("FancyURLopener", "urllib", "urllib.request"), - MovedAttribute("proxy_bypass", "urllib", "urllib.request"), -] -for attr in _urllib_request_moved_attributes: - setattr(Module_six_moves_urllib_request, attr.name, attr) -del attr - -Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes - -_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), - "moves.urllib_request", "moves.urllib.request") - - -class Module_six_moves_urllib_response(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_response""" - - -_urllib_response_moved_attributes = [ - MovedAttribute("addbase", "urllib", "urllib.response"), - MovedAttribute("addclosehook", "urllib", "urllib.response"), - MovedAttribute("addinfo", "urllib", "urllib.response"), - MovedAttribute("addinfourl", "urllib", "urllib.response"), -] -for attr in _urllib_response_moved_attributes: - setattr(Module_six_moves_urllib_response, attr.name, attr) -del attr - -Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes - -_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), - "moves.urllib_response", "moves.urllib.response") - - -class Module_six_moves_urllib_robotparser(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_robotparser""" - - -_urllib_robotparser_moved_attributes = [ - MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), -] -for attr in _urllib_robotparser_moved_attributes: - setattr(Module_six_moves_urllib_robotparser, attr.name, attr) -del attr - -Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes - -_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), - "moves.urllib_robotparser", "moves.urllib.robotparser") - - -class Module_six_moves_urllib(types.ModuleType): - """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" - __path__ = [] # mark as package - parse = _importer._get_module("moves.urllib_parse") - error = _importer._get_module("moves.urllib_error") - request = _importer._get_module("moves.urllib_request") - response = _importer._get_module("moves.urllib_response") - robotparser = _importer._get_module("moves.urllib_robotparser") - - def __dir__(self): - return ['parse', 'error', 'request', 'response', 'robotparser'] - -_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), - "moves.urllib") - - -def add_move(move): - """Add an item to six.moves.""" - setattr(_MovedItems, move.name, move) - - -def remove_move(name): - """Remove item from six.moves.""" - try: - delattr(_MovedItems, name) - except AttributeError: - try: - del moves.__dict__[name] - except KeyError: - raise AttributeError("no such move, %r" % (name,)) - - -if PY3: - _meth_func = "__func__" - _meth_self = "__self__" - - _func_closure = "__closure__" - _func_code = "__code__" - _func_defaults = "__defaults__" - _func_globals = "__globals__" -else: - _meth_func = "im_func" - _meth_self = "im_self" - - _func_closure = "func_closure" - _func_code = "func_code" - _func_defaults = "func_defaults" - _func_globals = "func_globals" - - -try: - advance_iterator = next -except NameError: - def advance_iterator(it): - return it.next() -next = advance_iterator - - -try: - callable = callable -except NameError: - def callable(obj): - return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) - - -if PY3: - def get_unbound_function(unbound): - return unbound - - create_bound_method = types.MethodType - - Iterator = object -else: - def get_unbound_function(unbound): - return unbound.im_func - - def create_bound_method(func, obj): - return types.MethodType(func, obj, obj.__class__) - - class Iterator(object): - - def next(self): - return type(self).__next__(self) - - callable = callable -_add_doc(get_unbound_function, - """Get the function out of a possibly unbound function""") - - -get_method_function = operator.attrgetter(_meth_func) -get_method_self = operator.attrgetter(_meth_self) -get_function_closure = operator.attrgetter(_func_closure) -get_function_code = operator.attrgetter(_func_code) -get_function_defaults = operator.attrgetter(_func_defaults) -get_function_globals = operator.attrgetter(_func_globals) - - -if PY3: - def iterkeys(d, **kw): - return iter(d.keys(**kw)) - - def itervalues(d, **kw): - return iter(d.values(**kw)) - - def iteritems(d, **kw): - return iter(d.items(**kw)) - - def iterlists(d, **kw): - return iter(d.lists(**kw)) - - viewkeys = operator.methodcaller("keys") - - viewvalues = operator.methodcaller("values") - - viewitems = operator.methodcaller("items") -else: - def iterkeys(d, **kw): - return iter(d.iterkeys(**kw)) - - def itervalues(d, **kw): - return iter(d.itervalues(**kw)) - - def iteritems(d, **kw): - return iter(d.iteritems(**kw)) - - def iterlists(d, **kw): - return iter(d.iterlists(**kw)) - - viewkeys = operator.methodcaller("viewkeys") - - viewvalues = operator.methodcaller("viewvalues") - - viewitems = operator.methodcaller("viewitems") - -_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") -_add_doc(itervalues, "Return an iterator over the values of a dictionary.") -_add_doc(iteritems, - "Return an iterator over the (key, value) pairs of a dictionary.") -_add_doc(iterlists, - "Return an iterator over the (key, [values]) pairs of a dictionary.") - - -if PY3: - def b(s): - return s.encode("latin-1") - def u(s): - return s - unichr = chr - if sys.version_info[1] <= 1: - def int2byte(i): - return bytes((i,)) - else: - # This is about 2x faster than the implementation above on 3.2+ - int2byte = operator.methodcaller("to_bytes", 1, "big") - byte2int = operator.itemgetter(0) - indexbytes = operator.getitem - iterbytes = iter - import io - StringIO = io.StringIO - BytesIO = io.BytesIO - _assertCountEqual = "assertCountEqual" - _assertRaisesRegex = "assertRaisesRegex" - _assertRegex = "assertRegex" -else: - def b(s): - return s - # Workaround for standalone backslash - def u(s): - return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") - unichr = unichr - int2byte = chr - def byte2int(bs): - return ord(bs[0]) - def indexbytes(buf, i): - return ord(buf[i]) - iterbytes = functools.partial(itertools.imap, ord) - import StringIO - StringIO = BytesIO = StringIO.StringIO - _assertCountEqual = "assertItemsEqual" - _assertRaisesRegex = "assertRaisesRegexp" - _assertRegex = "assertRegexpMatches" -_add_doc(b, """Byte literal""") -_add_doc(u, """Text literal""") - - -def assertCountEqual(self, *args, **kwargs): - return getattr(self, _assertCountEqual)(*args, **kwargs) - - -def assertRaisesRegex(self, *args, **kwargs): - return getattr(self, _assertRaisesRegex)(*args, **kwargs) - - -def assertRegex(self, *args, **kwargs): - return getattr(self, _assertRegex)(*args, **kwargs) - - -if PY3: - exec_ = getattr(moves.builtins, "exec") - - - def reraise(tp, value, tb=None): - if value is None: - value = tp() - if value.__traceback__ is not tb: - raise value.with_traceback(tb) - raise value - -else: - def exec_(_code_, _globs_=None, _locs_=None): - """Execute code in a namespace.""" - if _globs_ is None: - frame = sys._getframe(1) - _globs_ = frame.f_globals - if _locs_ is None: - _locs_ = frame.f_locals - del frame - elif _locs_ is None: - _locs_ = _globs_ - exec("""exec _code_ in _globs_, _locs_""") - - - exec_("""def reraise(tp, value, tb=None): - raise tp, value, tb -""") - - -if sys.version_info[:2] == (3, 2): - exec_("""def raise_from(value, from_value): - if from_value is None: - raise value - raise value from from_value -""") -elif sys.version_info[:2] > (3, 2): - exec_("""def raise_from(value, from_value): - raise value from from_value -""") -else: - def raise_from(value, from_value): - raise value - - -print_ = getattr(moves.builtins, "print", None) -if print_ is None: - def print_(*args, **kwargs): - """The new-style print function for Python 2.4 and 2.5.""" - fp = kwargs.pop("file", sys.stdout) - if fp is None: - return - def write(data): - if not isinstance(data, basestring): - data = str(data) - # If the file has an encoding, encode unicode with it. - if (isinstance(fp, file) and - isinstance(data, unicode) and - fp.encoding is not None): - errors = getattr(fp, "errors", None) - if errors is None: - errors = "strict" - data = data.encode(fp.encoding, errors) - fp.write(data) - want_unicode = False - sep = kwargs.pop("sep", None) - if sep is not None: - if isinstance(sep, unicode): - want_unicode = True - elif not isinstance(sep, str): - raise TypeError("sep must be None or a string") - end = kwargs.pop("end", None) - if end is not None: - if isinstance(end, unicode): - want_unicode = True - elif not isinstance(end, str): - raise TypeError("end must be None or a string") - if kwargs: - raise TypeError("invalid keyword arguments to print()") - if not want_unicode: - for arg in args: - if isinstance(arg, unicode): - want_unicode = True - break - if want_unicode: - newline = unicode("\n") - space = unicode(" ") - else: - newline = "\n" - space = " " - if sep is None: - sep = space - if end is None: - end = newline - for i, arg in enumerate(args): - if i: - write(sep) - write(arg) - write(end) -if sys.version_info[:2] < (3, 3): - _print = print_ - def print_(*args, **kwargs): - fp = kwargs.get("file", sys.stdout) - flush = kwargs.pop("flush", False) - _print(*args, **kwargs) - if flush and fp is not None: - fp.flush() - -_add_doc(reraise, """Reraise an exception.""") - -if sys.version_info[0:2] < (3, 4): - def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, - updated=functools.WRAPPER_UPDATES): - def wrapper(f): - f = functools.wraps(wrapped, assigned, updated)(f) - f.__wrapped__ = wrapped - return f - return wrapper -else: - wraps = functools.wraps - -def with_metaclass(meta, *bases): - """Create a base class with a metaclass.""" - # This requires a bit of explanation: the basic idea is to make a dummy - # metaclass for one level of class instantiation that replaces itself with - # the actual metaclass. - class metaclass(meta): - def __new__(cls, name, this_bases, d): - return meta(name, bases, d) - return type.__new__(metaclass, 'temporary_class', (), {}) - - -def add_metaclass(metaclass): - """Class decorator for creating a class with a metaclass.""" - def wrapper(cls): - orig_vars = cls.__dict__.copy() - slots = orig_vars.get('__slots__') - if slots is not None: - if isinstance(slots, str): - slots = [slots] - for slots_var in slots: - orig_vars.pop(slots_var) - orig_vars.pop('__dict__', None) - orig_vars.pop('__weakref__', None) - return metaclass(cls.__name__, cls.__bases__, orig_vars) - return wrapper - - -def python_2_unicode_compatible(klass): - """ - A decorator that defines __unicode__ and __str__ methods under Python 2. - Under Python 3 it does nothing. - - To support Python 2 and 3 with a single code base, define a __str__ method - returning text and apply this decorator to the class. - """ - if PY2: - if '__str__' not in klass.__dict__: - raise ValueError("@python_2_unicode_compatible cannot be applied " - "to %s because it doesn't define __str__()." % - klass.__name__) - klass.__unicode__ = klass.__str__ - klass.__str__ = lambda self: self.__unicode__().encode('utf-8') - return klass - - -# Complete the moves implementation. -# This code is at the end of this module to speed up module loading. -# Turn this module into a package. -__path__ = [] # required for PEP 302 and PEP 451 -__package__ = __name__ # see PEP 366 @ReservedAssignment -if globals().get("__spec__") is not None: - __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable -# Remove other six meta path importers, since they cause problems. This can -# happen if six is removed from sys.modules and then reloaded. (Setuptools does -# this for some reason.) -if sys.meta_path: - for i, importer in enumerate(sys.meta_path): - # Here's some real nastiness: Another "instance" of the six module might - # be floating around. Therefore, we can't use isinstance() to check for - # the six meta path importer, since the other six instance will have - # inserted an importer with different class. - if (type(importer).__name__ == "_SixMetaPathImporter" and - importer.name == __name__): - del sys.meta_path[i] - break - del i, importer -# Finally, add the importer to the meta path import hook. -sys.meta_path.append(_importer) diff --git a/wx/lib/softwareupdate.py b/wx/lib/softwareupdate.py index 40970e47..2b456dd5 100644 --- a/wx/lib/softwareupdate.py +++ b/wx/lib/softwareupdate.py @@ -30,7 +30,7 @@ import wx import sys import os import atexit -import wx.lib.six as six +import six if six.PY3: from urllib.request import urlopen diff --git a/wx/lib/wxcairo.py b/wx/lib/wxcairo.py index ad87c15c..3a4984ae 100644 --- a/wx/lib/wxcairo.py +++ b/wx/lib/wxcairo.py @@ -52,7 +52,7 @@ installer for the pycairo pacakge here: import wx -from wx.lib.six import PY3 +from six import PY3 import cairo import ctypes diff --git a/wx/py/filling.py b/wx/py/filling.py index 447afc00..0d58eaf1 100644 --- a/wx/py/filling.py +++ b/wx/py/filling.py @@ -5,7 +5,7 @@ __author__ = "Patrick K. O'Brien " # Tags: py3-port import wx -import wx.lib.six as six +import six from . import dispatcher from . import editwindow diff --git a/wx/py/images.py b/wx/py/images.py index 6a906f13..8ce7ee74 100644 --- a/wx/py/images.py +++ b/wx/py/images.py @@ -3,7 +3,7 @@ __author__ = "Patrick K. O'Brien / David Mashburn " import wx -from wx.lib.six import BytesIO +from six import BytesIO def getPyIcon(shellName='PyCrust'): icon = wx.Icon() diff --git a/wx/py/interpreter.py b/wx/py/interpreter.py index 0cf27d92..4a35fde6 100644 --- a/wx/py/interpreter.py +++ b/wx/py/interpreter.py @@ -10,7 +10,7 @@ from code import InteractiveInterpreter, compile_command from . import dispatcher from . import introspect import wx -import wx.lib.six +import six class Interpreter(InteractiveInterpreter): """Interpreter based on code.InteractiveInterpreter.""" @@ -25,7 +25,7 @@ class Interpreter(InteractiveInterpreter): self.stdout = stdout self.stderr = stderr if rawin: - from wx.lib.six.moves import builtins + from six.moves import builtins builtins.raw_input = rawin del builtins if showInterpIntro: @@ -57,7 +57,7 @@ class Interpreter(InteractiveInterpreter): delete that last list.""" # In case the command is unicode try encoding it - if not wx.lib.six.PY3: + if not six.PY3: if type(command) == unicode: try: command = command.encode('utf-8') diff --git a/wx/py/introspect.py b/wx/py/introspect.py index e968a709..bce3baf5 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -8,7 +8,7 @@ import inspect import tokenize import types import wx -from wx.lib.six import BytesIO, PY3, string_types +from six import BytesIO, PY3, string_types def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): diff --git a/wx/py/shell.py b/wx/py/shell.py index 0fb731f1..9d80eb70 100644 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -8,7 +8,7 @@ __author__ = "Patrick K. O'Brien " import wx from wx import stc -from wx.lib.six import PY3 +from six import PY3 import keyword import os @@ -382,7 +382,7 @@ class Shell(editwindow.EditWindow): This sets "close", "exit" and "quit" to a helpful string. """ - from wx.lib.six.moves import builtins + from six.moves import builtins builtins.close = builtins.exit = builtins.quit = \ 'Click on the close button to leave the application.' builtins.cd = cd diff --git a/wx/py/sliceshell.py b/wx/py/sliceshell.py index be656434..147cbaa7 100644 --- a/wx/py/sliceshell.py +++ b/wx/py/sliceshell.py @@ -15,7 +15,7 @@ __author__ += "Patrick K. O'Brien " import wx from wx import stc -from wx.lib.six import PY3 +from six import PY3 import keyword import os @@ -964,7 +964,7 @@ class SlicesShell(editwindow.EditWindow): This sets "close", "exit" and "quit" to a helpful string. """ - from wx.lib.six import PY3 + from six import PY3 if PY3: import builtins else: diff --git a/wx/tools/pywxrc.py b/wx/tools/pywxrc.py index 75872caf..aa384512 100644 --- a/wx/tools/pywxrc.py +++ b/wx/tools/pywxrc.py @@ -33,7 +33,7 @@ Usage: python pywxrc.py -h import sys, os, getopt, glob, re import xml.dom.minidom as minidom -from wx.lib.six import print_ +from six import print_ #----------------------------------------------------------------------