chiark / gitweb /
fix bare except to satisfy newer pycodestyle
[fdroidserver.git] / fdroidserver / common.py
index 5914109cd3b4d237256aea51c73c2a720d01f5c1..794504e311798a44a3b033caa73c1df40a80addf 100644 (file)
@@ -512,11 +512,23 @@ def publishednameinfo(filename):
     return result
 
 
-apk_release_filename = re.compile('(?P<appid>[a-z0-9_\.]+)_(?P<vercode>[0-9]+)\.apk')
-apk_release_filename_with_sigfp = re.compile('(?P<appid>[a-z0-9_\.]+)_(?P<vercode>[0-9]+)_(?P<sigfp>[0-9a-f]{7})\.apk')
+apk_release_filename = re.compile('(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)\.apk')
+apk_release_filename_with_sigfp = re.compile('(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)_(?P<sigfp>[0-9a-f]{7})\.apk')
 
 
 def apk_parse_release_filename(apkname):
+    """Parses the name of an APK file according the F-Droids APK naming
+    scheme and returns the tokens.
+
+    WARNING: Returned values don't necessarily represent the APKs actual
+    properties, the are just paresed from the file name.
+
+    :returns: A triplet containing (appid, versionCode, signer), where appid
+        should be the package name, versionCode should be the integer
+        represion of the APKs version and signer should be the first 7 hex
+        digists of the sha256 signing key fingerprint which was used to sign
+        this APK.
+    """
     m = apk_release_filename_with_sigfp.match(apkname)
     if m:
         return m.group('appid'), m.group('vercode'), m.group('sigfp')
@@ -2037,7 +2049,7 @@ def signer_fingerprint_short(sig):
     Extracts the first 7 hexadecimal digits of sha256 signing-key fingerprint
     for a given pkcs7 signature.
 
-    :param sig: Contents of an APK signature.
+    :param sig: Contents of an APK signing certificate.
     :returns: shortened signing-key fingerprint.
     """
     return signer_fingerprint(sig)[:7]
@@ -2194,7 +2206,7 @@ def apk_strip_signatures(signed_apk, strip_manifest=False):
 
 
 def apk_implant_signatures(apkpath, signaturefile, signedfile, manifest):
-    """Implats a signature from out metadata into an APK.
+    """Implats a signature from metadata into an APK.
 
     Note: this changes there supplied APK in place. So copy it if you
     need the original to be preserved.
@@ -2336,7 +2348,7 @@ def verify_apk_signature(apk, min_sdk_version=None):
         try:
             verify_jar_signature(apk)
             return True
-        except:
+        except Exception:
             pass
     return False