Replace finds with pythonic terms

This commit is contained in:
Daniel Martí 2013-12-20 09:34:03 +01:00
parent 8f3a2d4355
commit efc8317272
3 changed files with 8 additions and 10 deletions

View file

@ -1361,7 +1361,7 @@ def isApkDebuggable(apkfile, config):
print "ERROR: Failed to get apk manifest information" print "ERROR: Failed to get apk manifest information"
sys.exit(1) sys.exit(1)
for line in output.splitlines(): for line in output.splitlines():
if line.find('android:debuggable') != -1 and not line.endswith('0x0'): if 'android:debuggable' in line and not line.endswith('0x0'):
return True return True
return False return False

View file

@ -341,11 +341,10 @@ def parse_srclib(metafile, **kw):
if not line or line.startswith("#"): if not line or line.startswith("#"):
continue continue
index = line.find(':') try:
if index == -1: field, value = line.split(':',1)
except ValueError:
raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line) raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
field = line[:index]
value = line[index+1:]
if field == "Subdir": if field == "Subdir":
thisinfo[field] = value.split(',') thisinfo[field] = value.split(',')
@ -543,11 +542,10 @@ def parse_metadata(metafile):
if line.startswith("#"): if line.startswith("#"):
curcomments.append(line) curcomments.append(line)
continue continue
index = line.find(':') try:
if index == -1: field, value = line.split(':',1)
except ValueError:
raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line) raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
field = line[:index]
value = line[index+1:]
# Translate obsolete fields... # Translate obsolete fields...
if field == 'Market Version': if field == 'Market Version':

View file

@ -101,7 +101,7 @@ def main():
cwd=tmp_dir, stdout=subprocess.PIPE) cwd=tmp_dir, stdout=subprocess.PIPE)
out = p.communicate()[0] out = p.communicate()[0]
lines = out.splitlines() lines = out.splitlines()
if len(lines) != 1 or lines[0].find('META-INF') == -1: if len(lines) != 1 or 'META-INF' not in lines[0]:
raise Exception("Unexpected diff output - " + out) raise Exception("Unexpected diff output - " + out)
print "...successfully verified" print "...successfully verified"