* more fixes:

- sync more of Package attributes from specfile
  - naming changes
  - remove cruft
  - put gettext stuff
This commit is contained in:
Eray Özkural
2005-10-31 17:19:15 +00:00
parent bbbb681fc9
commit 0955ef30ca
+22 -29
View File
@@ -18,6 +18,10 @@
provides read and write routines for PSPEC files. provides read and write routines for PSPEC files.
""" """
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
# standard python modules # standard python modules
from os.path import basename from os.path import basename
@@ -149,9 +153,10 @@ class Source:
t_Packager = [Packager, xmlfile.mandatory] t_Packager = [Packager, xmlfile.mandatory]
t_Summary = [xmlfile.String, xmlfile.mandatory] t_Summary = [xmlfile.String, xmlfile.mandatory]
t_Description = [xmlfile.String, xmlfile.mandatory] t_Description = [xmlfile.String, xmlfile.mandatory]
t_License = [ [xmlfile.String], xmlfile.mandatory]
t_IsA = [ [xmlfile.String], xmlfile.mandatory] t_IsA = [ [xmlfile.String], xmlfile.mandatory]
t_PartOf = [xmlfile.String, xmlfile.mandatory] t_PartOf = [xmlfile.String, xmlfile.mandatory]
t_Icon = [ xmlfile.String, xmlfile.optional]
t_License = [ [xmlfile.String], xmlfile.mandatory]
t_Archive = [Archive, xmlfile.mandatory ] t_Archive = [Archive, xmlfile.mandatory ]
t_Patches = [ [Patch], xmlfile.optional] t_Patches = [ [Patch], xmlfile.optional]
t_BuildDependencies = [ [Dependency], xmlfile.optional] t_BuildDependencies = [ [Dependency], xmlfile.optional]
@@ -162,12 +167,17 @@ class Package:
t_Name = [ xmlfile.String, xmlfile.mandatory ] t_Name = [ xmlfile.String, xmlfile.mandatory ]
t_Summary = [ xmlfile.String, xmlfile.mandatory ] t_Summary = [ xmlfile.String, xmlfile.mandatory ]
t_Description = [ xmlfile.String, xmlfile.mandatory ] t_Description = [ xmlfile.String, xmlfile.mandatory ]
t_PartOf = [xmlfile.String, xmlfile.optional]
t_IsA = [ [xmlfile.String], xmlfile.optional] t_IsA = [ [xmlfile.String], xmlfile.optional]
t_PartOf = [xmlfile.String, xmlfile.optional]
t_License = [ [xmlfile.String], xmlfile.optional]
t_Icon = [ xmlfile.String, xmlfile.optional]
t_RuntimeDependencies = [ [Dependency], xmlfile.optional]
t_Files = [ [Path], xmlfile.optional]
t_Conflicts = [ [xmlfile.String], xmlfile.optional, "Conflicts/Package"] t_Conflicts = [ [xmlfile.String], xmlfile.optional, "Conflicts/Package"]
t_ProvidesComar = [ [ComarProvide], xmlfile.optional, "Provides/COMAR"] t_ProvidesComar = [ [ComarProvide], xmlfile.optional, "Provides/COMAR"]
#t_RequriesComar = [ [xmlfile.String], xmlfile.mandatory, "Requires/COMAR"] #t_RequiresComar = [ [xmlfile.String], xmlfile.mandatory, "Requires/COMAR"]
t_AdditionalFiles = [ [AdditionalFile], xmlfile.optional] t_AdditionalFiles = [ [AdditionalFile], xmlfile.optional]
t_History = [ [Update], xmlfile.optional]
class SpecFile(XmlFile): class SpecFile(XmlFile):
@@ -177,7 +187,7 @@ class SpecFile(XmlFile):
t_Source = [ Source, xmlfile.mandatory] t_Source = [ Source, xmlfile.mandatory]
t_Packages = [ [Package], xmlfile.mandatory, "Package"] t_Packages = [ [Package], xmlfile.mandatory, "Package"]
t_History = [ [Update], xmlfile.mandatory, "History/Update"] t_History = [ [Update], xmlfile.mandatory]
#we're not doing this with the init hook right now #we're not doing this with the init hook right now
#def init(self, tag = "PISI"): #def init(self, tag = "PISI"):
@@ -205,13 +215,12 @@ class SpecFile(XmlFile):
self.unlink() self.unlink()
errs = self.check()
errs = self.has_errors()
if errs: if errs:
e = "" e = ""
for x in errs: for x in errs:
e += x + "\n" e += x + "\n"
raise XmlError(_("File '%s' has errors:\n%s") % (filename, e)) raise Error(_("File '%s' has errors:\n%s") % (filename, e))
def override_tags(self): def override_tags(self):
"""Override tags from Source in Packages. Some tags in Packages """Override tags from Source in Packages. Some tags in Packages
@@ -227,8 +236,8 @@ class SpecFile(XmlFile):
if not pkg.description: if not pkg.description:
pkg.description = self.source.description pkg.description = self.source.description
if not pkg.partof: if not pkg.partOf:
pkg.partof = self.source.partof pkg.partOf = self.source.partOf
if not pkg.license: if not pkg.license:
pkg.license = self.source.license pkg.license = self.source.license
@@ -248,31 +257,15 @@ class SpecFile(XmlFile):
tmp = [] tmp = []
for pkg in self.packages: for pkg in self.packages:
if pkg.isa and self.source.isa: if pkg.isA and self.source.isA:
pkg.isa.append(self.source.isa) pkg.isA.append(self.source.isA)
elif not pkg.isa and self.source.isa: elif not pkg.isA and self.source.isA:
pkg.isa = self.source.isa pkg.isA = self.source.isA
tmp.append(pkg) tmp.append(pkg)
self.packages = tmp self.packages = tmp
def has_errors(self):
"""Return errors of the PSPEC file if there are any."""
#FIXME: has_errors name is misleading for a function that does
#not just return a boolean value. check() would be better - exa
err = Checks()
err.join(self.source.has_errors())
if len(self.packages) <= 0:
errs.add(_("There should be at least one Package section"))
for p in self.packages:
err.join(p.has_errors())
if len(self.history) <= 0:
err.add(_("Source needs some education in History :)"))
for update in self.history:
err.join(update.has_errors())
return err.list
def write(self, filename): def write(self, filename):
"""Write PSPEC file""" """Write PSPEC file"""
self.newDOM() self.newDOM()