Index: pylib/gyp/mac_tool.py |
diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py |
index 32aba14fe7600eb85da739158ea1663d351ac2e5..034dcb974e1183e5036e6d1e6ab4a005af52841b 100755 |
--- a/pylib/gyp/mac_tool.py |
+++ b/pylib/gyp/mac_tool.py |
@@ -8,6 +8,8 @@ |
These functions are executed via gyp-mac-tool when using the Makefile generator. |
""" |
+from __future__ import print_function |
+ |
import fcntl |
import fnmatch |
import glob |
@@ -16,7 +18,6 @@ import os |
import plistlib |
import re |
import shutil |
-import string |
import struct |
import subprocess |
import sys |
@@ -150,11 +151,11 @@ class MacTool(object): |
fp.close() |
return None |
fp.close() |
- if header.startswith("\xFE\xFF"): |
+ if header.startswith(b"\xFE\xFF"): |
return "UTF-16" |
- elif header.startswith("\xFF\xFE"): |
+ elif header.startswith(b"\xFF\xFE"): |
return "UTF-16" |
- elif header.startswith("\xEF\xBB\xBF"): |
+ elif header.startswith(b"\xEF\xBB\xBF"): |
return "UTF-8" |
else: |
return None |
@@ -169,7 +170,7 @@ class MacTool(object): |
# Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). |
plist = plistlib.readPlistFromString(lines) |
if keys: |
- plist = dict(plist.items() + json.loads(keys[0]).items()) |
+ plist.update(json.loads(keys[0])) |
lines = plistlib.writePlistToString(plist) |
# Go through all the environment variables and replace them as variables in |
@@ -180,7 +181,7 @@ class MacTool(object): |
continue |
evar = '${%s}' % key |
evalue = os.environ[key] |
- lines = string.replace(lines, evar, evalue) |
+ lines = lines.replace(evar, evalue) |
# Xcode supports various suffices on environment variables, which are |
# all undocumented. :rfc1034identifier is used in the standard project |
@@ -190,11 +191,11 @@ class MacTool(object): |
# in a URL either -- oops, hence :rfc1034identifier was born. |
evar = '${%s:identifier}' % key |
evalue = IDENT_RE.sub('_', os.environ[key]) |
- lines = string.replace(lines, evar, evalue) |
+ lines = lines.replace(evar, evalue) |
evar = '${%s:rfc1034identifier}' % key |
evalue = IDENT_RE.sub('-', os.environ[key]) |
- lines = string.replace(lines, evar, evalue) |
+ lines = lines.replace(evar, evalue) |
# Remove any keys with values that haven't been replaced. |
lines = lines.split('\n') |
@@ -265,7 +266,7 @@ class MacTool(object): |
_, err = libtoolout.communicate() |
for line in err.splitlines(): |
if not libtool_re.match(line) and not libtool_re5.match(line): |
- print >>sys.stderr, line |
+ print(line, file=sys.stderr) |
# Unconditionally touch the output .a file on the command line if present |
# and the command succeeded. A bit hacky. |
if not libtoolout.returncode: |
@@ -380,7 +381,7 @@ class MacTool(object): |
]) |
if keys: |
keys = json.loads(keys) |
- for key, value in keys.iteritems(): |
+ for key, value in keys.items(): |
arg_name = '--' + key |
if isinstance(value, bool): |
if value: |
@@ -472,8 +473,9 @@ class MacTool(object): |
profiles_dir = os.path.join( |
os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles') |
if not os.path.isdir(profiles_dir): |
- print >>sys.stderr, ( |
- 'cannot find mobile provisioning for %s' % bundle_identifier) |
+ print(( |
+ 'cannot find mobile provisioning for %s' % bundle_identifier), |
+ file=sys.stderr) |
sys.exit(1) |
provisioning_profiles = None |
if profile: |
@@ -494,8 +496,9 @@ class MacTool(object): |
valid_provisioning_profiles[app_id_pattern] = ( |
profile_path, profile_data, team_identifier) |
if not valid_provisioning_profiles: |
- print >>sys.stderr, ( |
- 'cannot find mobile provisioning for %s' % bundle_identifier) |
+ print(( |
+ 'cannot find mobile provisioning for %s' % bundle_identifier), |
+ file=sys.stderr) |
sys.exit(1) |
# If the user has multiple provisioning profiles installed that can be |
# used for ${bundle_identifier}, pick the most specific one (ie. the |
@@ -519,7 +522,7 @@ class MacTool(object): |
def _MergePlist(self, merged_plist, plist): |
"""Merge |plist| into |merged_plist|.""" |
- for key, value in plist.iteritems(): |
+ for key, value in plist.items(): |
if isinstance(value, dict): |
merged_value = merged_plist.get(key, {}) |
if isinstance(merged_value, dict): |
@@ -629,7 +632,7 @@ class MacTool(object): |
the key was not found. |
""" |
if isinstance(data, str): |
- for key, value in substitutions.iteritems(): |
+ for key, value in substitutions.items(): |
data = data.replace('$(%s)' % key, value) |
return data |
if isinstance(data, list): |