chiark / gitweb /
Improve checkupdates further, Auto Name works with gradle
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 13 Aug 2013 13:58:43 +0000 (15:58 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 13 Aug 2013 13:58:43 +0000 (15:58 +0200)
fdroidserver/checkupdates.py
fdroidserver/common.py

index ee80bca69291fdc9feb364c9feff1d2a4cbfa2b1..d030f4a61d1536096296b8b1fa96c3adfd3a2fc2 100644 (file)
@@ -304,15 +304,18 @@ def main():
                     vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir, sdk_path)
                     vcs.gotorevision(None)
 
+                    flavour = None
                     if len(app['builds']) > 0:
                         if 'subdir' in app['builds'][-1]:
                             app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
+                        if 'gradle' in app['builds'][-1]:
+                            flavour = app['builds'][-1]['gradle']
+
+                    new_name = common.fetch_real_name(app_dir, flavour)
+                    if new_name != app['Auto Name']:
+                        app['Auto Name'] = new_name
+                        writeit = True
 
-                    #new_name = common.fetch_real_name(app_dir)
-                    #if new_name != app['Auto Name']:
-                        #app['Auto Name'] = new_name
-                        #if not writeit:
-                            #writeit = True
                 except Exception:
                     msg = "Auto Name failed for  %s due to exception: %s" % (app['id'], traceback.format_exc())
 
index 6664ce6971b0c1dde1a7fc82dd65e928d5fc4507..4a188c082b289d0c955456645251a450859d9868 100644 (file)
@@ -862,21 +862,19 @@ def description_html(lines,linkres):
     ps.end()
     return ps.text_html
 
-def retrieve_string(app_dir, string_id):
-    string_search = re.compile(r'.*"'+string_id+'".*>([^<]+?)<.*').search
-    for xmlfile in glob.glob(os.path.join(
-            app_dir, 'res', 'values', '*.xml')):
+def retrieve_string(xml_dir, string):
+    print string
+    if not string.startswith('@string/'):
+        return string.replace("\\'","'")
+    string_search = re.compile(r'.*"'+string[8:]+'".*>([^<]+?)<.*').search
+    for xmlfile in glob.glob(os.path.join(xml_dir, '*.xml')):
         for line in file(xmlfile):
             matches = string_search(line)
             if matches:
-                s = matches.group(1)
-                if s.startswith('@string/'):
-                    return retrieve_string(app_dir, s[8:]);
-                return s.replace("\\'","'")
+                return retrieve_string(xml_dir, matches.group(1))
     return ''
 
-# Return list of existing AM.xml files that will be used to find the highest
-# vercode
+# Return list of existing files that will be used to find the highest vercode
 def manifest_paths(app_dir, flavour):
 
     possible_manifests = [ os.path.join(app_dir, 'AndroidManifest.xml'),
@@ -886,30 +884,30 @@ def manifest_paths(app_dir, flavour):
     if flavour is not None:
         possible_manifests.append(
                 os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml'))
-
+    
     return [path for path in possible_manifests if os.path.isfile(path)]
 
-
 # Retrieve the package name
-def fetch_real_name(app_dir):
+def fetch_real_name(app_dir, flavour):
     app_search = re.compile(r'.*<application.*').search
     name_search = re.compile(r'.*android:label="([^"]+)".*').search
     app_found = False
     name = None
-    for line in file(manifest_path(app_dir)):
-        if not app_found:
-            if app_search(line):
-                app_found = True
-        if app_found:
-            if name is not None:
-                break
-            matches = name_search(line)
-            if matches:
-                name = matches.group(1)
+    for f in manifest_paths(app_dir, flavour):
+        print f
+        if not f.endswith(".xml"):
+            continue
+        xml_dir = os.path.join(f[:-19], 'res', 'values')
+        for line in file(f):
+            if not app_found:
+                if app_search(line):
+                    app_found = True
+            if app_found:
+                matches = name_search(line)
+                if matches:
+                    return retrieve_string(xml_dir, matches.group(1))
 
-    if name.startswith('@string/'):
-        return retrieve_string(app_dir, name[8:])
-    return name
+    return ''
 
 # Extract some information from the AndroidManifest.xml at the given path.
 # Returns (version, vercode, package), any or all of which might be None.