Closer to working catalog creation.
This commit is contained in:
parent
1ab162d4d6
commit
4abdf82598
2 changed files with 44 additions and 17 deletions
|
@ -21,12 +21,12 @@ de = catalogProps.addChild('de')
|
|||
fr = catalogProps.addChild('fr')
|
||||
|
||||
urls = [
|
||||
"http://flightgear.wo0t.de/Aircraft-3.0/{acft}_20140116.zip",
|
||||
"http://ftp.icm.edu.pl/packages/flightgear/Aircraft-3.0/{acft}_20140216.zip",
|
||||
"http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/Aircraft-3.0/{acft}_20140216.zip",
|
||||
"http://ftp.igh.cnrs.fr/pub/flightgear/ftp/Aircraft-3.0/{acft}_20140116.zip",
|
||||
"http://ftp.linux.kiev.ua/pub/fgfs/Aircraft-3.0/{acft}_20140116.zip",
|
||||
"http://fgfs.physra.net/ftp/Aircraft-3.0/{acft}_20130225.zip"
|
||||
"http://flightgear.wo0t.de/",
|
||||
"http://ftp.icm.edu.pl/packages/flightgear/",
|
||||
"http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/",
|
||||
"http://ftp.igh.cnrs.fr/pub/flightgear/ftp/",
|
||||
"http://ftp.linux.kiev.ua/pub/fgfs/",
|
||||
"http://fgfs.physra.net/ftp/"
|
||||
]
|
||||
|
||||
thumbs = [
|
||||
|
@ -56,6 +56,8 @@ for d in os.listdir(aircraftDir):
|
|||
sim = props.getNode("sim")
|
||||
|
||||
pkgNode = catalogProps.addChild('package')
|
||||
|
||||
# basic / mandatory values
|
||||
pkgNode.addChild('id').value = d
|
||||
pkgNode.addChild('name').value = sim.getValue('description')
|
||||
|
||||
|
@ -63,14 +65,30 @@ for d in os.listdir(aircraftDir):
|
|||
if longDesc is not None:
|
||||
pkgNode.addChild('description').value = longDesc
|
||||
|
||||
# copy all the standard values
|
||||
for p in ['status', 'author', 'license']:
|
||||
v = sim.getValue(p)
|
||||
if v is not None:
|
||||
pkgNode.addChild(p).value = v
|
||||
|
||||
# ratings
|
||||
if sim.hasChild('rating'):
|
||||
pkgRatings = pkgNode.addChild('rating')
|
||||
for r in ['FDM', 'systems', 'cockpit', 'model']:
|
||||
pkgRatings.addChild(r).value = sim.getValue('rating/' + r, 0)
|
||||
|
||||
# copy tags
|
||||
if sim.hasChild('tags'):
|
||||
for c in sim.getChild('tags').getChildren('tag'):
|
||||
pkgNode.addChild('tag').value = c.value
|
||||
|
||||
pkgNode.addChild("md5").value = 'ffffffffff'
|
||||
|
||||
# create download and thumbnail URLs
|
||||
date = '0000000'
|
||||
s = "{url}Aircraft-3.0/{acft}_{date}.zip"
|
||||
for u in urls:
|
||||
pkgNode.addChild("url").value = u.format(acft=d)
|
||||
pkgNode.addChild("url").value = s.format(url=u,acft=d, date=date)
|
||||
|
||||
for t in thumbs:
|
||||
pkgNode.addChild("thumbnail").value = t.format(acft=d)
|
||||
|
|
29
sgprops.py
29
sgprops.py
|
@ -100,7 +100,7 @@ class Node(object):
|
|||
root = self._createXMLElement('PropertyList')
|
||||
|
||||
t = ET.ElementTree(root)
|
||||
t.write(path, 'UTF-8')
|
||||
t.write(path, 'utf-8')
|
||||
|
||||
def _createXMLElement(self, nm = None):
|
||||
if nm is None:
|
||||
|
@ -109,15 +109,24 @@ class Node(object):
|
|||
n = ET.Element(nm)
|
||||
|
||||
# value and type specification
|
||||
if self._value is not None:
|
||||
n.text = str(self._value)
|
||||
if isinstance(self._value, int):
|
||||
n.set('type', 'int')
|
||||
elif isinstance(self._value, float):
|
||||
n.set('type', 'double')
|
||||
elif isinstance(self._value, bool):
|
||||
n.set('type', "bool")
|
||||
|
||||
try:
|
||||
if self._value is not None:
|
||||
if isinstance(self._value, basestring):
|
||||
# don't call str() on strings, breaks the
|
||||
# encoding
|
||||
n.text = self._value
|
||||
else:
|
||||
# use str() to turn non-string types into text
|
||||
n.text = str(self._value)
|
||||
if isinstance(self._value, int):
|
||||
n.set('type', 'int')
|
||||
elif isinstance(self._value, float):
|
||||
n.set('type', 'double')
|
||||
elif isinstance(self._value, bool):
|
||||
n.set('type', "bool")
|
||||
except UnicodeEncodeError:
|
||||
print "Encoding error with", self._value, type(self._value)
|
||||
|
||||
# index in parent
|
||||
if (self.index != 0):
|
||||
n.set('n', self.index)
|
||||
|
|
Loading…
Reference in a new issue