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')
|
fr = catalogProps.addChild('fr')
|
||||||
|
|
||||||
urls = [
|
urls = [
|
||||||
"http://flightgear.wo0t.de/Aircraft-3.0/{acft}_20140116.zip",
|
"http://flightgear.wo0t.de/",
|
||||||
"http://ftp.icm.edu.pl/packages/flightgear/Aircraft-3.0/{acft}_20140216.zip",
|
"http://ftp.icm.edu.pl/packages/flightgear/",
|
||||||
"http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/Aircraft-3.0/{acft}_20140216.zip",
|
"http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/",
|
||||||
"http://ftp.igh.cnrs.fr/pub/flightgear/ftp/Aircraft-3.0/{acft}_20140116.zip",
|
"http://ftp.igh.cnrs.fr/pub/flightgear/ftp/",
|
||||||
"http://ftp.linux.kiev.ua/pub/fgfs/Aircraft-3.0/{acft}_20140116.zip",
|
"http://ftp.linux.kiev.ua/pub/fgfs/",
|
||||||
"http://fgfs.physra.net/ftp/Aircraft-3.0/{acft}_20130225.zip"
|
"http://fgfs.physra.net/ftp/"
|
||||||
]
|
]
|
||||||
|
|
||||||
thumbs = [
|
thumbs = [
|
||||||
|
@ -56,6 +56,8 @@ for d in os.listdir(aircraftDir):
|
||||||
sim = props.getNode("sim")
|
sim = props.getNode("sim")
|
||||||
|
|
||||||
pkgNode = catalogProps.addChild('package')
|
pkgNode = catalogProps.addChild('package')
|
||||||
|
|
||||||
|
# basic / mandatory values
|
||||||
pkgNode.addChild('id').value = d
|
pkgNode.addChild('id').value = d
|
||||||
pkgNode.addChild('name').value = sim.getValue('description')
|
pkgNode.addChild('name').value = sim.getValue('description')
|
||||||
|
|
||||||
|
@ -63,14 +65,30 @@ for d in os.listdir(aircraftDir):
|
||||||
if longDesc is not None:
|
if longDesc is not None:
|
||||||
pkgNode.addChild('description').value = longDesc
|
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
|
# copy tags
|
||||||
if sim.hasChild('tags'):
|
if sim.hasChild('tags'):
|
||||||
for c in sim.getChild('tags').getChildren('tag'):
|
for c in sim.getChild('tags').getChildren('tag'):
|
||||||
pkgNode.addChild('tag').value = c.value
|
pkgNode.addChild('tag').value = c.value
|
||||||
|
|
||||||
|
pkgNode.addChild("md5").value = 'ffffffffff'
|
||||||
|
|
||||||
# create download and thumbnail URLs
|
# create download and thumbnail URLs
|
||||||
|
date = '0000000'
|
||||||
|
s = "{url}Aircraft-3.0/{acft}_{date}.zip"
|
||||||
for u in urls:
|
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:
|
for t in thumbs:
|
||||||
pkgNode.addChild("thumbnail").value = t.format(acft=d)
|
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')
|
root = self._createXMLElement('PropertyList')
|
||||||
|
|
||||||
t = ET.ElementTree(root)
|
t = ET.ElementTree(root)
|
||||||
t.write(path, 'UTF-8')
|
t.write(path, 'utf-8')
|
||||||
|
|
||||||
def _createXMLElement(self, nm = None):
|
def _createXMLElement(self, nm = None):
|
||||||
if nm is None:
|
if nm is None:
|
||||||
|
@ -109,15 +109,24 @@ class Node(object):
|
||||||
n = ET.Element(nm)
|
n = ET.Element(nm)
|
||||||
|
|
||||||
# value and type specification
|
# value and type specification
|
||||||
if self._value is not None:
|
try:
|
||||||
n.text = str(self._value)
|
if self._value is not None:
|
||||||
if isinstance(self._value, int):
|
if isinstance(self._value, basestring):
|
||||||
n.set('type', 'int')
|
# don't call str() on strings, breaks the
|
||||||
elif isinstance(self._value, float):
|
# encoding
|
||||||
n.set('type', 'double')
|
n.text = self._value
|
||||||
elif isinstance(self._value, bool):
|
else:
|
||||||
n.set('type', "bool")
|
# 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
|
# index in parent
|
||||||
if (self.index != 0):
|
if (self.index != 0):
|
||||||
n.set('n', self.index)
|
n.set('n', self.index)
|
||||||
|
|
Loading…
Add table
Reference in a new issue