mirror of https://gitlab.com/ita1024/waf.git
Use splitlines when possible
This commit is contained in:
parent
340551d8a0
commit
80344dee5e
|
@ -22,7 +22,7 @@ file = open(name, 'r')
|
||||||
txt = file.read()
|
txt = file.read()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
lst = txt.split('\n')
|
lst = txt.splitlines()
|
||||||
for line in lst:
|
for line in lst:
|
||||||
source_filename = line.strip()
|
source_filename = line.strip()
|
||||||
if not source_filename: continue
|
if not source_filename: continue
|
||||||
|
|
|
@ -35,7 +35,7 @@ def gtest_results(bld):
|
||||||
|
|
||||||
# uncomment if you want to see what's happening
|
# uncomment if you want to see what's happening
|
||||||
# print(str(out, 'utf-8'))
|
# print(str(out, 'utf-8'))
|
||||||
output = str(out, 'utf-8').split('\n')
|
output = str(out, 'utf-8').splitlines()
|
||||||
for i, line in enumerate(output):
|
for i, line in enumerate(output):
|
||||||
if '[ RUN ]' in line and code:
|
if '[ RUN ]' in line and code:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ def get_suncc_version(conf, cc):
|
||||||
err = e.stderr
|
err = e.stderr
|
||||||
|
|
||||||
version = (out or err)
|
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
|
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)
|
match = version_re(version)
|
||||||
|
|
|
@ -63,7 +63,7 @@ def get_gfortran_version(conf, fc):
|
||||||
conf.fatal('Could not determine the compiler type')
|
conf.fatal('Could not determine the compiler type')
|
||||||
|
|
||||||
k = {}
|
k = {}
|
||||||
out = out.split('\n')
|
out = out.splitlines()
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
for line in out:
|
for line in out:
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ColorGCCFormatter(Logs.formatter):
|
||||||
cmd = frame.f_locals['cmd']
|
cmd = frame.f_locals['cmd']
|
||||||
if isinstance(cmd, list) and ('gcc' in cmd[0] or 'g++' in cmd[0]):
|
if isinstance(cmd, list) and ('gcc' in cmd[0] or 'g++' in cmd[0]):
|
||||||
lines = []
|
lines = []
|
||||||
for line in rec.msg.split('\n'):
|
for line in rec.msg.splitlines():
|
||||||
if 'warning: ' in line:
|
if 'warning: ' in line:
|
||||||
lines.append(self.colors.YELLOW + line)
|
lines.append(self.colors.YELLOW + line)
|
||||||
elif 'error: ' in line:
|
elif 'error: ' in line:
|
||||||
|
|
|
@ -32,7 +32,7 @@ class RcvtFormatter(Logs.formatter):
|
||||||
cmd = frame.f_locals['cmd']
|
cmd = frame.f_locals['cmd']
|
||||||
if isinstance(cmd, list) and ('armcc' in cmd[0] or 'armld' in cmd[0]):
|
if isinstance(cmd, list) and ('armcc' in cmd[0] or 'armld' in cmd[0]):
|
||||||
lines = []
|
lines = []
|
||||||
for line in rec.msg.split('\n'):
|
for line in rec.msg.splitlines():
|
||||||
if 'Warning: ' in line:
|
if 'Warning: ' in line:
|
||||||
lines.append(self.colors.YELLOW + line)
|
lines.append(self.colors.YELLOW + line)
|
||||||
elif 'Error: ' in line:
|
elif 'Error: ' in line:
|
||||||
|
|
|
@ -211,7 +211,7 @@ class cppcheck(Task.Task):
|
||||||
'''use cppcheck xml result string, add the command string used to invoke cppcheck
|
'''use cppcheck xml result string, add the command string used to invoke cppcheck
|
||||||
and save as xml file.
|
and save as xml file.
|
||||||
'''
|
'''
|
||||||
header = '%s\n' % s.split('\n')[0]
|
header = '%s\n' % s.splitlines()[0]
|
||||||
root = ElementTree.fromstring(s)
|
root = ElementTree.fromstring(s)
|
||||||
cmd = ElementTree.SubElement(root.find('cppcheck'), 'cmd')
|
cmd = ElementTree.SubElement(root.find('cppcheck'), 'cmd')
|
||||||
cmd.text = str(self.cmd)
|
cmd.text = str(self.cmd)
|
||||||
|
|
|
@ -41,7 +41,7 @@ def get_pgfortran_version(conf,fc):
|
||||||
conf.fatal('Could not determine the compiler type')
|
conf.fatal('Could not determine the compiler type')
|
||||||
k = {}
|
k = {}
|
||||||
prevk = ''
|
prevk = ''
|
||||||
out = out.split('\n')
|
out = out.splitlines()
|
||||||
for line in out:
|
for line in out:
|
||||||
lst = line.partition('=')
|
lst = line.partition('=')
|
||||||
if lst[1] == '=':
|
if lst[1] == '=':
|
||||||
|
|
|
@ -57,7 +57,7 @@ class protoc(Task):
|
||||||
if node in seen:
|
if node in seen:
|
||||||
return
|
return
|
||||||
seen.append(node)
|
seen.append(node)
|
||||||
code = node.read().split("\n")
|
code = node.read().splitlines()
|
||||||
for line in code:
|
for line in code:
|
||||||
m = re.search(r'^import\s+"(.*)";.*(//)?.*', line)
|
m = re.search(r'^import\s+"(.*)";.*(//)?.*', line)
|
||||||
if m:
|
if m:
|
||||||
|
|
2
wscript
2
wscript
|
@ -188,7 +188,7 @@ def process_tokens(tokens):
|
||||||
|
|
||||||
deco_re = re.compile('(def|class)\\s+(\w+)\\(.*')
|
deco_re = re.compile('(def|class)\\s+(\w+)\\(.*')
|
||||||
def process_decorators(body):
|
def process_decorators(body):
|
||||||
lst = body.split('\n')
|
lst = body.splitlines()
|
||||||
accu = []
|
accu = []
|
||||||
all_deco = []
|
all_deco = []
|
||||||
buf = [] # put the decorator lines
|
buf = [] # put the decorator lines
|
||||||
|
|
Loading…
Reference in New Issue