Skip to content

Commit 576f319

Browse files
committed
COMPAT: py3 compat for scripts/merge-pr.py
1 parent 0e7ae89 commit 576f319

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/merge-py.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import sys
3535
import textwrap
3636

37+
from six.moves import input
38+
3739
PANDAS_HOME = '.'
3840
PROJECT_NAME = 'pandas'
3941
print("PANDAS_HOME = " + PANDAS_HOME)
@@ -96,11 +98,11 @@ def run_cmd(cmd):
9698
if cmd is None:
9799
cmd = popenargs[0]
98100
raise subprocess.CalledProcessError(retcode, cmd, output=output)
99-
return output
101+
return six.text_type(output)
100102

101103

102104
def continue_maybe(prompt):
103-
result = raw_input("\n%s (y/n): " % prompt)
105+
result = input("\n%s (y/n): " % prompt)
104106
if result.lower() != "y":
105107
fail("Okay, exiting")
106108

@@ -114,7 +116,7 @@ def clean_up():
114116

115117
branches = run_cmd("git branch").replace(" ", "").split("\n")
116118

117-
for branch in filter(lambda x: x.startswith(BRANCH_PREFIX), branches):
119+
for branch in [b for b in branches if x.startswith(BRANCH_PREFIX)]:
118120
print("Deleting local branch %s" % branch)
119121
run_cmd("git branch -D %s" % branch)
120122

@@ -199,7 +201,7 @@ def merge_pr(pr_num, target_ref):
199201

200202

201203
def cherry_pick(pr_num, merge_hash, default_branch):
202-
pick_ref = raw_input("Enter a branch name [%s]: " % default_branch)
204+
pick_ref = input("Enter a branch name [%s]: " % default_branch)
203205
if pick_ref == "":
204206
pick_ref = default_branch
205207

@@ -245,7 +247,7 @@ def fix_version_from_branch(branch, versions):
245247
# Assumes branch names can be sorted lexicographically
246248
# latest_branch = sorted(branch_names, reverse=True)[0]
247249

248-
pr_num = raw_input("Which pull request would you like to merge? (e.g. 34): ")
250+
pr_num = input("Which pull request would you like to merge? (e.g. 34): ")
249251
pr = get_json("%s/pulls/%s" % (GITHUB_API_BASE, pr_num))
250252

251253
url = pr["url"]

0 commit comments

Comments
 (0)