* automxl: inheritance support

* make metadata use inheritance
This commit is contained in:
Eray Özkural
2005-11-03 15:19:43 +00:00
parent 25b3306027
commit a46fbcd563
3 changed files with 28 additions and 30 deletions
+4 -2
View File
@@ -85,8 +85,10 @@ Legend:
+ improved error handling, check routines, hooks, format/print routines
+ xmlfile support (read/write)
+ string member, in addition to tag/attribute members
/ replace specfile with new specfile using autoxml
- revise writing, error checking, printing and tests
+ replace specfile with new specfile using autoxml
+ autoxmlize: metadata, index, dependency and related code paths
+ inheritance support
/ revise writing, error checking, printing and tests
/ components and distribution (eray)
+ requirements
/ xml format
+4 -21
View File
@@ -35,26 +35,9 @@ class Source:
t_Homepage = [xmlfile.String, xmlfile.optional]
t_Packager = [specfile.Packager, xmlfile.mandatory]
# FIXME: make inheritance work with autoxml (specfile.Package)
class Package:
class Package(specfile.Package):
__metaclass__ = xmlfile.autoxml
# FIXME: copied attributes
t_Name = [ xmlfile.String, xmlfile.mandatory ]
t_Summary = [ xmlfile.LocalText, xmlfile.optional ]
t_Description = [ xmlfile.LocalText, 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 = [ [specfile.Dependency], xmlfile.optional]
t_Files = [ [specfile.Path], xmlfile.optional]
t_Conflicts = [ [xmlfile.String], xmlfile.optional, "Conflicts/Package"]
t_ProvidesComar = [ [specfile.ComarProvide], xmlfile.optional, "Provides/COMAR"]
#t_RequiresComar = [ [xmlfile.String], xmlfile.mandatory, "Requires/COMAR"]
t_AdditionalFiles = [ [specfile.AdditionalFile], xmlfile.optional]
t_History = [ [specfile.Update], xmlfile.optional]
t_Build = [ xmlfile.Integer, xmlfile.optional]
t_Distribution = [ xmlfile.String, xmlfile.mandatory]
t_DistributionRelease = [ xmlfile.String, xmlfile.mandatory]
@@ -66,9 +49,9 @@ class Package:
self.version = self.history[0].version
self.release = self.history[0].release
def __str__(self):
s = specfile.Package.__str__(self)
return s
#def __str__(self):
#s = specfile.Package.__str__(self)
#return s
def pkg_dir(self):
packageDir = self.name + '-' \
+20 -7
View File
@@ -226,6 +226,8 @@ class autoxml(oo.autosuper, oo.autoprop):
xmlfile_support = XmlFile in bases
cls.autoxml_bases = filter(lambda base: isinstance(base, autoxml), bases)
#TODO: initialize class attribute __xml_tags
#setattr(cls, 'xml_variables', [])
@@ -266,9 +268,12 @@ class autoxml(oo.autosuper, oo.autoprop):
#FIXME: what the hell is spec? :(
if not tag:
tag = cls.tag
#self.__super.__init__(tag = tag) #FIXME: doesn't work, why? :(
super(cls, self).__init__(tag = tag) # tag for XmlFile support
for init in self.__class__.initializers:
if xmlfile_support:
XmlFile.__init__(self, tag = tag)
for base in cls.autoxml_bases:
base.__init__(self)
#super(cls, self).__init__(tag = tag) cooperative shit disabled for now
for init in inits:#self.__class__.initializers:
init(self)
# init hook
if hasattr(self, 'init'):
@@ -278,7 +283,9 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.decoders = decoders
def decode(self, node, errs, where = unicode()):
for decode_member in self.__class__.decoders:
for base in cls.autoxml_bases:
base.decode(self, node, errs, where)
for decode_member in decoders:#self.__class__.decoders:
decode_member(self, node, errs, where)
if hasattr(self, 'decode_hook'):
self.decode_hook(node, errs, where)
@@ -286,7 +293,9 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.encoders = encoders
def encode(self, xml, node, errs):
for encode_member in self.__class__.encoders:
for base in cls.autoxml_bases:
base.encode(self, xml, node, errs)
for encode_member in encoders:#self.__class__.encoders:
encode_member(self, xml, node, errs)
if hasattr(self, 'encode_hook'):
self.encode_hook(xml, node, errs)
@@ -295,7 +304,9 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.errorss = errorss
def errors(self, where = unicode()):
errs = []
for errors in self.__class__.errorss:
for base in cls.autoxml_bases:
errs.extend(base.errors(self, where))
for errors in errorss:#self.__class__.errorss:
errs.extend(errors(self, where))
if hasattr(self, 'errors_hook'):
errs.extend(self.errors_hook(where))
@@ -304,7 +315,9 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.formatters = formatters
def format(self, f, errs):
for formatter in self.__class__.formatters:
for base in cls.autoxml_bases:
base.format(self, f, errs)
for formatter in formatters:#self.__class__.formatters:
formatter(self, f, errs)
cls.format = format
def print_text(self, file = sys.stdout):