mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-15 17:20:07 +01:00
remove more Python2 hybridation
This commit is contained in:
committed by
Scott Talbert
parent
0257f755cf
commit
323e78c085
@@ -18,8 +18,6 @@ import subprocess
|
||||
from buildtools import builder
|
||||
from buildtools.config import getVisCVersion
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
# builder object
|
||||
wxBuilder = None
|
||||
|
||||
@@ -427,8 +425,7 @@ def main(wxDir, args):
|
||||
setupFile = os.path.join(mswIncludeDir, "setup.h")
|
||||
with open(setupFile, "rb") as f:
|
||||
setupText = f.read()
|
||||
if PY3:
|
||||
setupText = setupText.decode('utf-8')
|
||||
setupText = setupText.decode('utf-8')
|
||||
|
||||
for flag in flags:
|
||||
setupText, subsMade = re.subn(flag + r"\s+?\d", "%s %s" % (flag, flags[flag]), setupText)
|
||||
@@ -437,8 +434,7 @@ def main(wxDir, args):
|
||||
sys.exit(1)
|
||||
|
||||
with open(setupFile, "wb") as f:
|
||||
if PY3:
|
||||
setupText = setupText.encode('utf-8')
|
||||
setupText = setupText.encode('utf-8')
|
||||
f.write(setupText)
|
||||
|
||||
args = []
|
||||
|
||||
@@ -485,18 +485,8 @@ class Configuration(object):
|
||||
|
||||
def build_locale_list(self, srcdir):
|
||||
# get a list of all files under the srcdir, to be used for install_data
|
||||
if sys.version_info[0] == 2:
|
||||
def walk_helper(lst, dirname, files):
|
||||
for f in files:
|
||||
filename = opj(dirname, f)
|
||||
if not os.path.isdir(filename):
|
||||
lst.append( (dirname, [filename]) )
|
||||
file_list = []
|
||||
os.path.walk(srcdir, walk_helper, file_list)
|
||||
return file_list
|
||||
else:
|
||||
# TODO: Python3 version using os.walk generator
|
||||
return []
|
||||
# TODO: Python3 version using os.walk generator
|
||||
return []
|
||||
|
||||
|
||||
def find_data_files(self, srcdir, *wildcards, **kw):
|
||||
@@ -916,8 +906,7 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True, onError=None):
|
||||
if getOutput:
|
||||
outputEncoding = 'cp1252' if sys.platform == 'win32' else 'utf-8'
|
||||
output = sp.stdout.read()
|
||||
if sys.version_info > (3,):
|
||||
output = output.decode(outputEncoding)
|
||||
output = output.decode(outputEncoding)
|
||||
output = output.rstrip()
|
||||
|
||||
rval = sp.wait()
|
||||
@@ -936,11 +925,8 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True, onError=None):
|
||||
|
||||
|
||||
def myExecfile(filename, ns):
|
||||
if sys.version_info < (3,):
|
||||
execfile(filename, ns)
|
||||
else:
|
||||
with open(filename, 'r') as f:
|
||||
exec(f.read(), ns)
|
||||
with open(filename, 'r') as f:
|
||||
exec(f.read(), ns)
|
||||
|
||||
|
||||
def textfile_open(filename, mode='rt'):
|
||||
@@ -950,12 +936,7 @@ def textfile_open(filename, mode='rt'):
|
||||
mode parameter must include the 't' to put the stream into text mode.
|
||||
"""
|
||||
assert 't' in mode
|
||||
if sys.version_info < (3,):
|
||||
import codecs
|
||||
mode = mode.replace('t', '')
|
||||
return codecs.open(filename, mode, encoding='utf-8')
|
||||
else:
|
||||
return open(filename, mode, encoding='utf-8')
|
||||
return open(filename, mode, encoding='utf-8')
|
||||
|
||||
|
||||
def getSipFiles(names):
|
||||
|
||||
@@ -315,7 +315,7 @@ distutils.cygwinccompiler.CygwinCCompiler._compile = _compile
|
||||
# into the .pyd files as expected. So we'll strip out that option via
|
||||
# a monkey-patch of the msvc9compiler.MSVCCompiler.initialize method.
|
||||
|
||||
if os.name == 'nt' and sys.version_info >= (2,6):
|
||||
if os.name == 'nt':
|
||||
import distutils.msvc9compiler
|
||||
_orig_initialize = distutils.msvc9compiler.MSVCCompiler.initialize
|
||||
|
||||
|
||||
Reference in New Issue
Block a user