chiark / gitweb /
Replace finds with pythonic terms
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 20 Dec 2013 08:34:03 +0000 (09:34 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 20 Dec 2013 08:34:03 +0000 (09:34 +0100)
fdroidserver/common.py
fdroidserver/metadata.py
fdroidserver/verify.py

index eaebe41f56b60b2fb304b5ef8c15a794d616bb11..d2f3e018b6089fa62a4d231ab04550792f8f14a3 100644 (file)
@@ -1361,7 +1361,7 @@ def isApkDebuggable(apkfile, config):
         print "ERROR: Failed to get apk manifest information"
         sys.exit(1)
     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 False
 
index f52fc878cdcbb5296af5e9abecd2ee0dd72ef5e1..2deb1a4ac1b92bef8a93039d3911a5a370de314f 100644 (file)
@@ -341,11 +341,10 @@ def parse_srclib(metafile, **kw):
         if not line or line.startswith("#"):
             continue
 
-        index = line.find(':')
-        if index == -1:
+        try:
+            field, value = line.split(':',1)
+        except ValueError:
             raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
-        field = line[:index]
-        value = line[index+1:]
 
         if field == "Subdir":
             thisinfo[field] = value.split(',')
@@ -543,11 +542,10 @@ def parse_metadata(metafile):
             if line.startswith("#"):
                 curcomments.append(line)
                 continue
-            index = line.find(':')
-            if index == -1:
+            try:
+                field, value = line.split(':',1)
+            except ValueError:
                 raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
-            field = line[:index]
-            value = line[index+1:]
 
             # Translate obsolete fields...
             if field == 'Market Version':
index 1c0c6b46fb3ca606b43f5455654c17f1ea250697..a9f18392e4227695376b6f409f6ec31ad21c8911 100644 (file)
@@ -101,7 +101,7 @@ def main():
                 cwd=tmp_dir, stdout=subprocess.PIPE)
             out = p.communicate()[0]
             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)
 
             print "...successfully verified"