1
0
Fork 0

Catalogs: Thumbnail extraction works.

This commit is contained in:
James Turner 2015-07-14 21:37:39 -05:00
parent 5944ad64d9
commit 8d1e9abcc9

View file

@ -14,9 +14,11 @@ import git_discrete_repository
# TODO # TODO
# uploading / rsyncing # uploading / rsyncing
thumbnailNames = ["thumbnail.png", "thumbnail.jpg"]
class VariantData: class VariantData:
def __init__(self, primary, path, node): def __init__(self, path, node):
self._primary = primary #self._primary = primary
self._path = path self._path = path
self._name = node.getValue("sim/description") self._name = node.getValue("sim/description")
@ -62,6 +64,10 @@ class PackageData:
def path(self): def path(self):
return self._path return self._path
@property
def variants(self):
return self._variants
@property @property
def scmRevision(self): def scmRevision(self):
currentRev = scmRepo.scmRevisionForPath(self._path) currentRev = scmRepo.scmRevisionForPath(self._path)
@ -87,14 +93,14 @@ class PackageData:
continue continue
p = os.path.join(self._path, f) p = os.path.join(self._path, f)
node = readProps(p) node = sgprops.readProps(p)
simNode = node.getChild("sim") simNode = node.getChild("sim")
if (simNode.getValue("exclude")): if (simNode.getValue("exclude", False)):
continue continue
primary = simNode.getValue("variant-of", None) primary = simNode.getValue("variant-of", None)
if primary: if primary:
if not primary in variants: if not primary in self.variants:
self._variants[primary] = [] self._variants[primary] = []
self._variants[primary].append(VariantData(self, node)) self._variants[primary].append(VariantData(self, node))
continue continue
@ -105,10 +111,11 @@ class PackageData:
else: else:
foundPrimary = True; foundPrimary = True;
parsePrimarySetNode(simNode) self.parsePrimarySetNode(simNode)
if os.path.exists(os.path.join(self._path, "thumbnail.png")): for n in thumbnailNames:
self._thumbnails.append("thumbnail.png") if os.path.exists(os.path.join(self._path, n)):
self._thumbnails.append(n)
if not foundPrimary: if not foundPrimary:
raise RuntimeError("No primary -set.xml found at:" + self._path) raise RuntimeError("No primary -set.xml found at:" + self._path)
@ -118,7 +125,6 @@ class PackageData:
def parsePrimarySetNode(self, sim): def parsePrimarySetNode(self, sim):
# basic / mandatory values # basic / mandatory values
self._node.addChild('id').value = d
self._node.addChild('name').value = sim.getValue('description') self._node.addChild('name').value = sim.getValue('description')
longDesc = sim.getValue('long-description') longDesc = sim.getValue('long-description')
@ -145,7 +151,7 @@ class PackageData:
else: else:
self._node.addChild('tag').value = c.value self._node.addChild('tag').value = c.value
self._thumbnails = (t.value for t in self.getChildren("thumbnail")) self._thumbnails.append(t.value for t in sim.getChildren("thumbnail"))
def validate(self): def validate(self):
for t in self._thumbnails: for t in self._thumbnails:
@ -312,6 +318,8 @@ mirrorUrls = (m.value for m in config.getChildren("mirror"))
packagesToGenerate = [] packagesToGenerate = []
for p in packages.values(): for p in packages.values():
p.scanSetXmlFiles()
if (p.isSourceModified(scmRepo)): if (p.isSourceModified(scmRepo)):
packagesToGenerate.append(p) packagesToGenerate.append(p)
else: else: