chiark / gitweb /
Open metadata files in only one place
[fdroidserver.git] / fdroidserver / import.py
index 3256aaef2f83119dd2dbc75ecc6d9aa5cb7c709a..e1d69c3c3eb91f63bcbf65469775d74ff8404735 100644 (file)
@@ -79,20 +79,20 @@ def get_metadata_from_url(app, url):
 
     # Figure out what kind of project it is...
     projecttype = None
-    app['Web Site'] = url  # by default, we might override it
+    app.WebSite = url  # by default, we might override it
     if url.startswith('git://'):
         projecttype = 'git'
         repo = url
         repotype = 'git'
-        app['Source Code'] = ""
-        app['Web Site'] = ""
+        app.SourceCode = ""
+        app.WebSite = ""
     elif url.startswith('https://github.com'):
         projecttype = 'github'
         repo = url
         repotype = 'git'
-        app['Source Code'] = url
-        app['Issue Tracker'] = url + '/issues'
-        app['Web Site'] = ""
+        app.SourceCode = url
+        app.IssueTracker = url + '/issues'
+        app.WebSite = ""
     elif url.startswith('https://gitlab.com/'):
         projecttype = 'gitlab'
         # git can be fussy with gitlab URLs unless they end in .git
@@ -101,16 +101,16 @@ def get_metadata_from_url(app, url):
         else:
             repo = url + '.git'
         repotype = 'git'
-        app['Source Code'] = url + '/tree/HEAD'
-        app['Issue Tracker'] = url + '/issues'
+        app.SourceCode = url + '/tree/HEAD'
+        app.IssueTracker = url + '/issues'
     elif url.startswith('https://bitbucket.org/'):
         if url.endswith('/'):
             url = url[:-1]
         projecttype = 'bitbucket'
-        app['Source Code'] = url + '/src'
-        app['Issue Tracker'] = url + '/issues'
+        app.SourceCode = url + '/src'
+        app.IssueTracker = url + '/issues'
         # Figure out the repo type and adddress...
-        repotype, repo = getrepofrompage(app['Source Code'])
+        repotype, repo = getrepofrompage(app.SourceCode)
         if not repotype:
             logging.error("Unable to determine vcs type. " + repo)
             sys.exit(1)
@@ -139,8 +139,8 @@ def get_metadata_from_url(app, url):
     vcs.gotorevision(options.rev)
     root_dir = get_subdir(build_dir)
 
-    app['Repo Type'] = repotype
-    app['Repo'] = repo
+    app.RepoType = repotype
+    app.Repo = repo
 
     return root_dir, build_dir
 
@@ -174,9 +174,8 @@ def main():
     config = common.read_config(options)
 
     apps = metadata.read_metadata()
-    package, app = metadata.get_default_app_info_list(apps)
-    app['id'] = None
-    app['Update Check Mode'] = "Tags"
+    app = metadata.App()
+    app.UpdateCheckMode = "Tags"
 
     root_dir = None
     build_dir = None
@@ -185,7 +184,7 @@ def main():
         root_dir, build_dir = get_metadata_from_url(app, options.url)
     elif os.path.isdir('.git'):
         if options.url:
-            app['Web Site'] = options.url
+            app.WebSite = options.url
         root_dir = get_subdir(os.getcwd())
     else:
         logging.error("Specify project url.")
@@ -223,22 +222,17 @@ def main():
         sys.exit(1)
 
     # Create a build line...
-    build = {}
-    build['version'] = version or '?'
-    build['vercode'] = vercode or '?'
-    build['commit'] = '?'
-    build['disable'] = 'Generated by import.py - check/set version fields and commit id'
+    build = metadata.Build()
+    build.version = version or '?'
+    build.vercode = vercode or '?'
+    build.commit = '?'
+    build.disable = 'Generated by import.py - check/set version fields and commit id'
     if options.subdir:
-        build['subdir'] = options.subdir
+        build.subdir = options.subdir
     if os.path.exists(os.path.join(root_dir, 'jni')):
-        build['buildjni'] = ['yes']
+        build.buildjni = ['yes']
 
-    for flag, value in metadata.flag_defaults.iteritems():
-        if flag in build:
-            continue
-        build[flag] = value
-
-    app['builds'].append(build)
+    app.builds.append(build)
 
     # Keep the repo directory to save bandwidth...
     if not os.path.exists('build'):
@@ -246,7 +240,7 @@ def main():
     if build_dir is not None:
         shutil.move(build_dir, os.path.join('build', package))
     with open('build/.fdroidvcs-' + package, 'w') as f:
-        f.write(app['Repo Type'] + ' ' + app['Repo'])
+        f.write(app.RepoType + ' ' + app.Repo)
 
     metadatapath = os.path.join('metadata', package + '.txt')
     with open(metadatapath, 'w') as f: