Skip to content

Commit faf6e4b

Browse files
author
MarcoFalke
committed
Use str.splitlines where appropriate
1 parent 219de7d commit faf6e4b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

backport.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Attr:
7272
if not execute:
7373
print('set -e')
7474
for t in to_backport:
75-
msg = t[1].message.rstrip().split('\n')
75+
msg = t[1].message.rstrip().splitlines()
7676
assert(msg[1] == '')
7777
print('{a.hsh}# {a.head}{}{a.reset}'.format(msg[0],a=Attr))
7878
# XXX get the commits in the merge from the actual commit data instead of from the commit message

build-for-compare.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def objdump_all(srcdir: str, tgtdir: str):
164164
# postprocess- break into sections separated by 'Disassembly of section...'
165165
sections = defaultdict(list)
166166
funcname = ''
167-
for line in out.split('\n'):
167+
for line in out.splitlines():
168168
match = re.match('^Disassembly of section (.*):$', line)
169169
if match:
170170
funcname = match.group(1)

github-merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_acks_from_comments(head_commit, comments):
173173
head_abbrev = head_commit[0:6]
174174
acks = []
175175
for c in comments:
176-
review = [l for l in c['body'].split('\r\n') if 'ACK' in l and head_abbrev in l]
176+
review = [l for l in c['body'].splitlines() if 'ACK' in l and head_abbrev in l]
177177
if review:
178178
acks.append((c['user']['login'], review[0]))
179179
return acks

list-pulls.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def remove_last(l):
154154
# set of all commits
155155
commits = subprocess.check_output([GIT, 'rev-list', '--reverse', '--topo-order', ref_from+'..'+ref_to])
156156
commits = commits.decode()
157-
commits = remove_last(commits.split('\n'))
157+
commits = remove_last(commits.splitlines())
158158
commits_list = commits
159159
commits = set(commits)
160160

@@ -166,7 +166,7 @@ def remove_last(l):
166166
info = subprocess.check_output([GIT, 'show', '-s', '--format=%B%x00%P', commit])
167167
info = info.decode()
168168
(message, parents) = info.split('\0')
169-
title = message.rstrip().split('\n')[0]
169+
title = message.rstrip().splitlines()[0]
170170
parents = parents.rstrip().split(' ')
171171
commit_data[commit] = CommitData(commit, message, title, parents)
172172

@@ -182,7 +182,7 @@ def parse_commit_message(msg):
182182
Parse backport commit message.
183183
'''
184184
retval = CommitMetaData()
185-
for line in msg.split('\n'):
185+
for line in msg.splitlines():
186186
m = re.match('Github-Pull: #?(\d+)', line, re.I)
187187
if m:
188188
retval.pull = int(m.group(1))
@@ -210,7 +210,7 @@ def parse_commit_message(msg):
210210
#print('removing ', c.sha)
211211
sub_commits = subprocess.check_output([GIT, 'rev-list', c.parents[0]+'..'+c.parents[1]])
212212
sub_commits = sub_commits.decode()
213-
sub_commits = set(sub_commits.rstrip().split('\n'))
213+
sub_commits = set(sub_commits.rstrip().splitlines())
214214
pull = int(match.group(1))
215215

216216
# remove commits that are not in the global list

0 commit comments

Comments
 (0)