mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 07:20:29 +03:00
support app metadata in YAML format
YAML is a format that is quite similar to the .txt format, but is a widespread standard that has editing modes in popular editors. It is also easily parsable in python. The .pickle for testing is a lightly edited version of the real metadata for org.videolan.vlc: * comments were removed
This commit is contained in:
parent
0b62e7f22a
commit
32e257d742
5 changed files with 6427 additions and 1 deletions
|
|
@ -25,6 +25,15 @@ import glob
|
|||
import cgi
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
# use libyaml if it is available
|
||||
try:
|
||||
from yaml import CLoader
|
||||
YamlLoader = CLoader
|
||||
except ImportError:
|
||||
from yaml import Loader
|
||||
YamlLoader = Loader
|
||||
|
||||
# use the C implementation when available
|
||||
import xml.etree.cElementTree as ElementTree
|
||||
|
||||
|
|
@ -500,6 +509,11 @@ def read_metadata(xref=True):
|
|||
check_metadata(appinfo)
|
||||
apps[appid] = appinfo
|
||||
|
||||
for metafile in sorted(glob.glob(os.path.join('metadata', '*.yaml'))):
|
||||
appid, appinfo = parse_yaml_metadata(metafile)
|
||||
check_metadata(appinfo)
|
||||
apps[appid] = appinfo
|
||||
|
||||
if xref:
|
||||
# Parse all descriptions at load time, just to ensure cross-referencing
|
||||
# errors are caught early rather than when they hit the build server.
|
||||
|
|
@ -774,6 +788,18 @@ def parse_xml_metadata(metafile):
|
|||
return (appid, thisinfo)
|
||||
|
||||
|
||||
def parse_yaml_metadata(metafile):
|
||||
|
||||
appid = os.path.basename(metafile)[0:-5] # strip path and .yaml
|
||||
thisinfo = get_default_app_info_list(appid)
|
||||
|
||||
yamlinfo = yaml.load(open(metafile, 'r'), Loader=YamlLoader)
|
||||
thisinfo.update(yamlinfo)
|
||||
post_metadata_parse(thisinfo)
|
||||
|
||||
return (appid, thisinfo)
|
||||
|
||||
|
||||
def parse_txt_metadata(metafile):
|
||||
|
||||
appid = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue