Use splitlines when possible

This commit is contained in:
Thomas Nagy 2015-03-03 12:19:25 +01:00
parent 340551d8a0
commit 80344dee5e
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
10 changed files with 10 additions and 10 deletions

View File

@ -22,7 +22,7 @@ file = open(name, 'r')
txt = file.read()
file.close()
lst = txt.split('\n')
lst = txt.splitlines()
for line in lst:
source_filename = line.strip()
if not source_filename: continue

View File

@ -35,7 +35,7 @@ def gtest_results(bld):
# uncomment if you want to see what's happening
# print(str(out, 'utf-8'))
output = str(out, 'utf-8').split('\n')
output = str(out, 'utf-8').splitlines()
for i, line in enumerate(output):
if '[ RUN ]' in line and code:
i += 1

View File

@ -1093,7 +1093,7 @@ def get_suncc_version(conf, cc):
err = e.stderr
version = (out or err)
version = version.split('\n')[0]
version = version.splitlines()[0]
version_re = re.compile(r'cc:\s+sun\s+(c\+\+|c)\s+(?P<major>\d*)\.(?P<minor>\d*)', re.I).search
match = version_re(version)

View File

@ -63,7 +63,7 @@ def get_gfortran_version(conf, fc):
conf.fatal('Could not determine the compiler type')
k = {}
out = out.split('\n')
out = out.splitlines()
import shlex
for line in out:

View File

@ -21,7 +21,7 @@ class ColorGCCFormatter(Logs.formatter):
cmd = frame.f_locals['cmd']
if isinstance(cmd, list) and ('gcc' in cmd[0] or 'g++' in cmd[0]):
lines = []
for line in rec.msg.split('\n'):
for line in rec.msg.splitlines():
if 'warning: ' in line:
lines.append(self.colors.YELLOW + line)
elif 'error: ' in line:

View File

@ -32,7 +32,7 @@ class RcvtFormatter(Logs.formatter):
cmd = frame.f_locals['cmd']
if isinstance(cmd, list) and ('armcc' in cmd[0] or 'armld' in cmd[0]):
lines = []
for line in rec.msg.split('\n'):
for line in rec.msg.splitlines():
if 'Warning: ' in line:
lines.append(self.colors.YELLOW + line)
elif 'Error: ' in line:

View File

@ -211,7 +211,7 @@ class cppcheck(Task.Task):
'''use cppcheck xml result string, add the command string used to invoke cppcheck
and save as xml file.
'''
header = '%s\n' % s.split('\n')[0]
header = '%s\n' % s.splitlines()[0]
root = ElementTree.fromstring(s)
cmd = ElementTree.SubElement(root.find('cppcheck'), 'cmd')
cmd.text = str(self.cmd)

View File

@ -41,7 +41,7 @@ def get_pgfortran_version(conf,fc):
conf.fatal('Could not determine the compiler type')
k = {}
prevk = ''
out = out.split('\n')
out = out.splitlines()
for line in out:
lst = line.partition('=')
if lst[1] == '=':

View File

@ -57,7 +57,7 @@ class protoc(Task):
if node in seen:
return
seen.append(node)
code = node.read().split("\n")
code = node.read().splitlines()
for line in code:
m = re.search(r'^import\s+"(.*)";.*(//)?.*', line)
if m:

View File

@ -188,7 +188,7 @@ def process_tokens(tokens):
deco_re = re.compile('(def|class)\\s+(\w+)\\(.*')
def process_decorators(body):
lst = body.split('\n')
lst = body.splitlines()
accu = []
all_deco = []
buf = [] # put the decorator lines