Pisi error message sanitization

* pisi/specfile.py (_set_i18n): Handle parsing errors during
translations.xml reading.
* pisi/specfile.py (read_translations): Ignore source package
translations if <Name> is empty in translations.xml.
This commit is contained in:
Ozan Çağlayan
2010-01-19 12:08:10 +00:00
parent d39c4c82a0
commit 186bfada9f
2 changed files with 18 additions and 5 deletions
+6
View File
@@ -1,3 +1,9 @@
2010-01-19 Ozan Çağlayan <ozan@pardus.org.tr>
* pisi/specfile.py (_set_i18n): Handle parsing errors during
translations.xml reading.
* pisi/specfile.py (read_translations): Ignore source package
translations if <Name> is empty in translations.xml.
2010-01-12 Ozan Çağlayan <ozan@pardus.org.tr>
* pisi/actionsapi/get.py: Add ARCH() for getting host architecture.
Thanks to 64-bit team for pointing out this requirement.
+12 -5
View File
@@ -310,10 +310,14 @@ class SpecFile(xmlfile.XmlFile):
self.source.description["en"] = self.source.summary["en"]
def _set_i18n(self, tag, inst):
for summary in tag.tags("Summary"):
inst.summary[summary.getAttribute("xml:lang")] = summary.firstChild().data()
for desc in tag.tags("Description"):
inst.description[desc.getAttribute("xml:lang")] = desc.firstChild().data()
try:
for summary in tag.tags("Summary"):
inst.summary[summary.getAttribute("xml:lang")] = summary.firstChild().data()
for desc in tag.tags("Description"):
inst.description[desc.getAttribute("xml:lang")] = desc.firstChild().data()
except AttributeError:
raise Error(_("translations.xml file is badly formed."))
def read_translations(self, path):
if not os.path.exists(path):
@@ -323,7 +327,10 @@ class SpecFile(xmlfile.XmlFile):
except Exception, e:
raise Error(_("File '%s' has invalid XML") % (path) )
self._set_i18n(doc.getTag("Source"), self.source)
if doc.getTag("Source").getTagData("Name") == self.source.name:
# Set source package translations
self._set_i18n(doc.getTag("Source"), self.source)
for pak in doc.tags("Package"):
for inst in self.packages:
if inst.name == pak.getTagData("Name"):