Skip to content

Commit c404785

Browse files
authored
Merge pull request #3061 from alexwlchan/awlc/patch-2
Minor Python tidies in swift-api-dump.py
2 parents 5dd3ce9 + 5bf26ca commit c404785

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

utils/swift-api-dump.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ def run_command(args):
119119
def collect_submodules(common_args, module):
120120
# Execute swift-ide-test to print the interface.
121121
my_args = ['-module-print-submodules', '-module-to-print=%s' % (module)]
122-
(exitcode, out, err) = run_command(common_args + my_args)
122+
(exitcode, out, _) = run_command(common_args + my_args)
123123
if exitcode != 0:
124124
print(
125125
'error: submodule collection failed for module %s with error %d' %
126126
(module, exitcode))
127127
return ()
128128

129129
# Find all of the submodule imports.
130-
import_matcher = re.compile('.*import\s+%s\.([A-Za-z_0-9.]+)' % (module))
130+
import_matcher = re.compile(r'.*import\s+%s\.([A-Za-z_0-9.]+)' % (module))
131131
submodules = set()
132132
for line in out.splitlines():
133133
match = import_matcher.match(line)
@@ -140,10 +140,10 @@ def collect_submodules(common_args, module):
140140

141141

142142
def print_command(cmd, outfile=""):
143-
str = " ".join(cmd)
143+
retstr = " ".join(cmd)
144144
if outfile != "":
145-
str += " > " + outfile
146-
print(str)
145+
retstr += " > " + outfile
146+
print(retstr)
147147

148148
# Dump the API for the given module.
149149

@@ -200,15 +200,15 @@ def pretty_sdk_name(sdk):
200200

201201

202202
def collect_frameworks(sdk):
203-
(exitcode, sdk_path, err) = run_command(
203+
(exitcode, sdk_path, _) = run_command(
204204
["xcrun", "--show-sdk-path", "-sdk", sdk])
205205
if exitcode != 0:
206206
print('error: framework collection failed to find SDK path for %s '
207207
'with error %d' % (sdk, exitcode))
208208
return ()
209209
sdk_path = sdk_path.rstrip()
210210

211-
(exitcode, sdk_version, err) = run_command(
211+
(exitcode, sdk_version, _) = run_command(
212212
["xcrun", "--show-sdk-version", "-sdk", sdk])
213213
if exitcode != 0:
214214
print('error: framework collection failed to find SDK version for %s '
@@ -221,7 +221,7 @@ def collect_frameworks(sdk):
221221

222222
# Collect all of the framework names
223223
frameworks_dir = '%s/System/Library/Frameworks' % sdk_path
224-
framework_matcher = re.compile('([A-Za-z_0-9.]+)\.framework')
224+
framework_matcher = re.compile(r'([A-Za-z_0-9.]+)\.framework')
225225
frameworks = set()
226226
for entry in os.listdir(frameworks_dir):
227227
match = framework_matcher.match(entry)
@@ -234,8 +234,7 @@ def collect_frameworks(sdk):
234234

235235

236236
def create_dump_module_api_args(cmd_common, cmd_extra_args, sdk, module,
237-
target, source_filename, output_dir, quiet,
238-
verbose):
237+
target, output_dir, quiet, verbose):
239238

240239
# Determine the SDK root and collect the set of frameworks.
241240
(frameworks, sdk_root) = collect_frameworks(sdk)
@@ -302,7 +301,7 @@ def main():
302301
for sdk in args.sdk:
303302
jobs = jobs + create_dump_module_api_args(
304303
cmd_common, extra_args, sdk, args.module,
305-
args.target, source_filename, args.output_dir,
304+
args.target, args.output_dir,
306305
args.quiet, args.verbose)
307306

308307
# Execute the API dumps

0 commit comments

Comments
 (0)