chiark / gitweb /
remove support for XML app metadata, its broken
authorHans-Christoph Steiner <hans@eds.org>
Wed, 23 Nov 2016 14:01:23 +0000 (15:01 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 5 Dec 2016 19:16:54 +0000 (20:16 +0100)
JSON and YAML are very closely related, so supporting both of them is
basically almost no extra work.  Both are also closely related to how
Python works with dicts and pickles. XML is a very different beast, and its
not popular for this kind of thing anyway, so just purge it.

examples/config.py
fdroidserver/metadata.py
tests/metadata.TestCase
tests/metadata/net.osmand.plus.pickle [deleted file]
tests/metadata/net.osmand.plus.xml [deleted file]
tests/run-tests
tests/update.TestCase

index 4181037ed13834e0d3af40946fd3d89aa65f88aa..9ccdc5c92681510b5c46e9758f93bc1e9c91def2 100644 (file)
@@ -240,8 +240,7 @@ The repository of older versions of applications from the main demo repository.
 # build_server_always = True
 
 # By default, fdroid will use YAML .yml and the custom .txt metadata formats. It
-# is also possible to have metadata in JSON and XML by adding 'json' and
-# 'xml'.
+# is also possible to have metadata in JSON by adding 'json'.
 # accepted_formats = ['txt', 'yml']
 
 # Limit in number of characters that fields can take up
index 212128f38998fca7802e1073d898f5357c63b941..2d2a5bf1c088b69fcf5a1bc6dac7e19413ce0422 100644 (file)
@@ -35,9 +35,6 @@ except ImportError:
     from yaml import Loader
     YamlLoader = Loader
 
-# use the C implementation when available
-import xml.etree.cElementTree as ElementTree
-
 import fdroidserver.common
 
 srclibs = None
@@ -804,10 +801,8 @@ def read_metadata(xref=True, check_vcs=[]):
 
     for metadatapath in sorted(glob.glob(os.path.join('metadata', '*.txt'))
                                + glob.glob(os.path.join('metadata', '*.json'))
-                               + glob.glob(os.path.join('metadata', '*.xml'))
                                + glob.glob(os.path.join('metadata', '*.yml'))
                                + glob.glob('.fdroid.json')
-                               + glob.glob('.fdroid.xml')
                                + glob.glob('.fdroid.yml')):
         packageName, _ = fdroidserver.common.get_extension(os.path.basename(metadatapath))
         if packageName in apps:
@@ -987,8 +982,6 @@ def parse_metadata(metadatapath, check_vcs=False):
             parse_txt_metadata(mf, app)
         elif ext == 'json':
             parse_json_metadata(mf, app)
-        elif ext == 'xml':
-            parse_xml_metadata(mf, app)
         elif ext == 'yml':
             parse_yaml_metadata(mf, app)
         else:
@@ -1032,38 +1025,6 @@ def parse_json_metadata(mf, app):
     return app
 
 
-def parse_xml_metadata(mf, app):
-
-    tree = ElementTree.ElementTree(file=mf)
-    root = tree.getroot()
-
-    if root.tag != 'resources':
-        warn_or_exception('resources file does not have root element <resources/>')
-
-    for child in root:
-        if child.tag != 'builds':
-            # builds does not have name="" attrib
-            name = child.attrib['name']
-
-        if child.tag == 'string':
-            app.set_field(name, child.text)
-        elif child.tag == 'string-array':
-            for item in child:
-                app.append_field(name, item.text)
-        elif child.tag == 'builds':
-            for b in child:
-                build = Build()
-                for key in b:
-                    build.set_flag(key.tag, key.text)
-                app.builds.append(build)
-
-    # TODO handle this using <xsd:element type="xsd:boolean> in a schema
-    if not isinstance(app.RequiresRoot, bool):
-        app.RequiresRoot = app.RequiresRoot == 'true'
-
-    return app
-
-
 def parse_yaml_metadata(mf, app):
 
     yamlinfo = yaml.load(mf, Loader=YamlLoader)
index 0cdf3164861576067019e8815b7662a8ecd1190a..d68756f08b48659e90ad1d5b17d39e1fadb9c2f5 100755 (executable)
@@ -33,11 +33,11 @@ class MetadataTest(unittest.TestCase):
         config = dict()
         config['sdk_path'] = '/opt/android-sdk'
         config['ndk_paths'] = dict()
-        config['accepted_formats'] = ['json', 'txt', 'xml', 'yml']
+        config['accepted_formats'] = ['json', 'txt', 'yml']
         fdroidserver.common.config = config
 
         apps = fdroidserver.metadata.read_metadata(xref=True)
-        for appid in ('org.smssecure.smssecure', 'org.adaway', 'net.osmand.plus', 'org.videolan.vlc'):
+        for appid in ('org.smssecure.smssecure', 'org.adaway', 'org.videolan.vlc'):
             app = apps[appid]
             savepath = os.path.join('metadata', appid + '.pickle')
             frommeta = app.field_dict()
diff --git a/tests/metadata/net.osmand.plus.pickle b/tests/metadata/net.osmand.plus.pickle
deleted file mode 100644 (file)
index 7640971..0000000
Binary files a/tests/metadata/net.osmand.plus.pickle and /dev/null differ
diff --git a/tests/metadata/net.osmand.plus.xml b/tests/metadata/net.osmand.plus.xml
deleted file mode 100644 (file)
index 4b7ac8a..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<resources>
-  <string-array name="AntiFeatures">
-    <item>Tracking</item>
-    <item>NonFreeNet</item>
-  </string-array>
-
-  <string-array name="Categories">
-    <item>Navigation</item>
-  </string-array>
-
-  <string name="License">GPLv3</string>
-  <string name="Web Site">http://osmand.net</string>
-  <string name="Source Code">https://github.com/osmandapp/Osmand</string>
-  <string name="Issue Tracker">https://github.com/osmandapp/Osmand/issues</string>
-  <string name="Donate">https://code.google.com/p/osmand/#Please_support_the_project</string>
-
-  <string name="Name">OsmAnd~</string>
-  <string name="Summary">Offline/online maps and navigation</string>
-  <string name="Description">Osmand~'s features can be extended by enabling the plugins via the settings,
-which include online maps from many sources, tracking, OpenStreetMap (OSM) editing and
-accessibility enhancements.
-
-Map data of both vector and raster types can be stored on the phone memory
-card for offline usage, and navigation by default uses offline methods. Map
-data packages for many territories can be downloaded from within the app and
-there is a desktop program available on the website as well for creating your
-own.
-
-Anti-Features: Tracking - It will send your device and application specs to an
-Analytics server upon downloading the list of maps you can download.
-
-[https://osmandapp.github.io/changes.html Changelog]
-</string>
-
-  <string name="Repo Type">git</string>
-  <string name="Repo">https://github.com/mvdan/OsmAnd-submodules</string>
-<!--  <string name="Repo">https://github.com/osmandapp/Osmand</string/ -->
-
-<!--
-# Old builds with the old repo
-#Build:0.6.5,34
-#    commit=v0.6.5
-#    subdir=OsmAnd
-#    encoding=utf-8
-#    prebuild=mkdir assets && \
-#        mkdir raw
-#
-#Build:0.6.6,36
-#    commit=v0.6.6_2
-#    subdir=OsmAnd
-#    encoding=utf-8
-#    prebuild=mkdir raw
-#
-#Build:0.6.7,37
-#    commit=v0.6.7
-#    subdir=OsmAnd
-#    encoding=utf-8
-#    patch=code37.patch
-#    prebuild=mkdir raw
-#
-#Build:0.6.8,39
-#    commit=v0.6.8
-#    subdir=OsmAnd
-#    encoding=utf-8
-#    prebuild=mkdir raw
-#
-#Build:0.6.8',41
-#    disable=No corresponding source for whatever this is
-#    commit=unknown - see disabled
-#
-#Build:0.6.9,42
-#    commit=v0.6.9
-#    subdir=OsmAnd
-#    encoding=utf-8
-#    prebuild=mkdir raw
-#
-#Build:0.6.9',43
-#    disable=No corresponding source for whatever this is
-#    commit=unknown - see disabled
-#
-#Build:0.8.1,65
-#    commit=d62472532d8
-#    subdir=OsmAnd
-#    target=android-8
-#    init=rm -f build.xml
-#    encoding=utf-8
-#    forceversion=yes
-#    prebuild=cd ../DataExtractionOSM && \
-#        ant compile build && \
-#        cd ../OsmAnd/ && \
-#        cp ../DataExtractionOSM/build/OsmAndMapCreator.jar libs/ && \
-#        zip -d libs/OsmAndMapCreator.jar net/osmand/LogUtil.class && \
-#        cp -r ../DataExtractionOSM/build/lib/ libs/
-#    buildjni=no
-#
-#Build:0.8.2,71
-#    commit=50a4733475cd
-#    subdir=OsmAnd
-#    submodules=yes
-#    target=android-8
-#    init=rm -f build.xml
-#    encoding=utf-8
-#    forceversion=yes
-#    forcevercode=yes
-#    prebuild=cd ../DataExtractionOSM && \
-#        ant compile build && \
-#        cd ../OsmAnd/ && \
-#        sed -i 's/app_version">[^<]*/app_version">0.8.2-fdroid/' res/values/no_translate.xml && \
-#        cp ../DataExtractionOSM/build/OsmAndMapCreator.jar libs/ && \
-#        zip -d libs/OsmAndMapCreator.jar net/osmand/LogUtil.class && \
-#        cp -r ../DataExtractionOSM/build/lib/ libs/
-#    buildjni=yes
--->
-
-<builds>
-
-  <build>
-    <versionCode>182</versionCode>
-    <versionName>1.8.2</versionName>
-    <commit>76ada6c8a08afe69acb755503373ac36328ef665</commit>
-    <subdir>android/OsmAnd</subdir>
-    <submodules>true</submodules>
-    <output>bin/OsmAnd-release-unsigned.apk</output>
-    <prebuild>sed -i 's/"OsmAnd+"/"OsmAnd~"/g' build.xml</prebuild>
-    <build>./old-ndk-build.sh &amp;&amp; ant -Dsdk.dir="$ANDROID_SDK" -Dndk.dir="$ANDROID_NDK" -DBLACKBERRY_BUILD=false -DBUILD_SUFFIX= -DAPK_NUMBER_VERSION=182 "-DFEATURES=+play_market +gps_status -parking_plugin -blackberry -amazon -route_nav" -DCLEAN_CPP=false -DPACKAGE_TO_BUILT=net.osmand.plus -DAPK_VERSION=1.8.2 -Dnet.osmand.plus= -Dbuild.version=1.8.2 -Dbuild.version.code=182 -Dnativeoff=false "-DversionFeatures=+play_market +gps_status -parking_plugin -blackberry -amazon -route_nav" clean release</build>
-    <buildjni>no</buildjni>
-  </build>
-
-  <build>
-    <versionName>1.8.3</versionName>
-    <versionCode>183</versionCode>
-    <commit>1.8.3</commit>
-    <subdir>android/OsmAnd</subdir>
-    <submodules>true</submodules>
-    <output>bin/OsmAnd-release-unsigned.apk</output>
-    <build>../../build</build>
-    <buildjni>no</buildjni>
-  </build>
-
-  <build>
-    <versionName>1.9.4</versionName>
-    <versionCode>196</versionCode>
-    <commit>1.9.4</commit>
-    <subdir>android/OsmAnd</subdir>
-    <submodules>true</submodules>
-    <output>bin/OsmAnd-release-unsigned.apk</output>
-    <build>../../build</build>
-    <buildjni>no</buildjni>
-    <ndk>r10d</ndk>
-  </build>
-
-  <build>
-    <versionName>1.9.5</versionName>
-    <versionCode>197</versionCode>
-    <commit>1.9.5</commit>
-    <subdir>android/OsmAnd</subdir>
-    <submodules>true</submodules>
-    <output>bin/OsmAnd-release-unsigned.apk</output>
-    <build>../../build</build>
-    <buildjni>no</buildjni>
-    <ndk>r10d</ndk>
-  </build>
-
-</builds>
-
-  <string name="Maintainer Notes">
-No UCMs apply because git never contains actual releases, only pre-releses.
-
-The build instructions have been moved to a script in the root of the repo,
-'build'. This way it can be updated along with the submodules.
-  </string>
-
-  <string name="Auto Update Mode">None</string>
-  <string name="Update Check Mode">None</string>
-  <string name="Current Version">1.9.5</string>
-  <string name="Current Version Code">197</string>
-
-</resources>
\ No newline at end of file
index 354e6782210c77a99105fd64f25b162ed1c8c9e8..fd58024ac0d7cafb82b491f12fc4a242fca9f629 100755 (executable)
@@ -163,7 +163,7 @@ $fdroid init
 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $REPOROOT/
 cp -a $WORKSPACE/tests/gnupghome $GNUPGHOME
 chmod 0700 $GNUPGHOME
-echo "accepted_formats = ['json', 'txt', 'xml', 'yml']" >> config.py
+echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
 echo "install_list = 'org.adaway'" >> config.py
 echo "uninstall_list = {'com.android.vending', 'com.facebook.orca',}" >> config.py
 echo "gpghome = '$GNUPGHOME'" >> config.py
index 25e59a83531931ef606357850d998cfa54e6c161..12adce75161fca74fb5583797585a25bd3c36a1b 100755 (executable)
@@ -91,7 +91,7 @@ class UpdateTest(unittest.TestCase):
         config = dict()
         fdroidserver.common.fill_config_defaults(config)
         config['ndk_paths'] = dict()
-        config['accepted_formats'] = ['json', 'txt', 'xml', 'yml']
+        config['accepted_formats'] = ['json', 'txt', 'yml']
         fdroidserver.common.config = config
         fdroidserver.update.config = config