* automxl: inheritance support
* make metadata use inheritance
This commit is contained in:
@@ -85,8 +85,10 @@ Legend:
|
|||||||
+ improved error handling, check routines, hooks, format/print routines
|
+ improved error handling, check routines, hooks, format/print routines
|
||||||
+ xmlfile support (read/write)
|
+ xmlfile support (read/write)
|
||||||
+ string member, in addition to tag/attribute members
|
+ string member, in addition to tag/attribute members
|
||||||
/ replace specfile with new specfile using autoxml
|
+ replace specfile with new specfile using autoxml
|
||||||
- revise writing, error checking, printing and tests
|
+ autoxmlize: metadata, index, dependency and related code paths
|
||||||
|
+ inheritance support
|
||||||
|
/ revise writing, error checking, printing and tests
|
||||||
/ components and distribution (eray)
|
/ components and distribution (eray)
|
||||||
+ requirements
|
+ requirements
|
||||||
/ xml format
|
/ xml format
|
||||||
|
|||||||
+4
-21
@@ -35,26 +35,9 @@ class Source:
|
|||||||
t_Homepage = [xmlfile.String, xmlfile.optional]
|
t_Homepage = [xmlfile.String, xmlfile.optional]
|
||||||
t_Packager = [specfile.Packager, xmlfile.mandatory]
|
t_Packager = [specfile.Packager, xmlfile.mandatory]
|
||||||
|
|
||||||
# FIXME: make inheritance work with autoxml (specfile.Package)
|
class Package(specfile.Package):
|
||||||
class Package:
|
|
||||||
__metaclass__ = xmlfile.autoxml
|
__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_Build = [ xmlfile.Integer, xmlfile.optional]
|
||||||
t_Distribution = [ xmlfile.String, xmlfile.mandatory]
|
t_Distribution = [ xmlfile.String, xmlfile.mandatory]
|
||||||
t_DistributionRelease = [ xmlfile.String, xmlfile.mandatory]
|
t_DistributionRelease = [ xmlfile.String, xmlfile.mandatory]
|
||||||
@@ -66,9 +49,9 @@ class Package:
|
|||||||
self.version = self.history[0].version
|
self.version = self.history[0].version
|
||||||
self.release = self.history[0].release
|
self.release = self.history[0].release
|
||||||
|
|
||||||
def __str__(self):
|
#def __str__(self):
|
||||||
s = specfile.Package.__str__(self)
|
#s = specfile.Package.__str__(self)
|
||||||
return s
|
#return s
|
||||||
|
|
||||||
def pkg_dir(self):
|
def pkg_dir(self):
|
||||||
packageDir = self.name + '-' \
|
packageDir = self.name + '-' \
|
||||||
|
|||||||
+20
-7
@@ -226,6 +226,8 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
|
|
||||||
xmlfile_support = XmlFile in bases
|
xmlfile_support = XmlFile in bases
|
||||||
|
|
||||||
|
cls.autoxml_bases = filter(lambda base: isinstance(base, autoxml), bases)
|
||||||
|
|
||||||
#TODO: initialize class attribute __xml_tags
|
#TODO: initialize class attribute __xml_tags
|
||||||
#setattr(cls, 'xml_variables', [])
|
#setattr(cls, 'xml_variables', [])
|
||||||
|
|
||||||
@@ -266,9 +268,12 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
#FIXME: what the hell is spec? :(
|
#FIXME: what the hell is spec? :(
|
||||||
if not tag:
|
if not tag:
|
||||||
tag = cls.tag
|
tag = cls.tag
|
||||||
#self.__super.__init__(tag = tag) #FIXME: doesn't work, why? :(
|
if xmlfile_support:
|
||||||
super(cls, self).__init__(tag = tag) # tag for XmlFile support
|
XmlFile.__init__(self, tag = tag)
|
||||||
for init in self.__class__.initializers:
|
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(self)
|
||||||
# init hook
|
# init hook
|
||||||
if hasattr(self, 'init'):
|
if hasattr(self, 'init'):
|
||||||
@@ -278,7 +283,9 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
|
|
||||||
cls.decoders = decoders
|
cls.decoders = decoders
|
||||||
def decode(self, node, errs, where = unicode()):
|
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)
|
decode_member(self, node, errs, where)
|
||||||
if hasattr(self, 'decode_hook'):
|
if hasattr(self, 'decode_hook'):
|
||||||
self.decode_hook(node, errs, where)
|
self.decode_hook(node, errs, where)
|
||||||
@@ -286,7 +293,9 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
|
|
||||||
cls.encoders = encoders
|
cls.encoders = encoders
|
||||||
def encode(self, xml, node, errs):
|
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)
|
encode_member(self, xml, node, errs)
|
||||||
if hasattr(self, 'encode_hook'):
|
if hasattr(self, 'encode_hook'):
|
||||||
self.encode_hook(xml, node, errs)
|
self.encode_hook(xml, node, errs)
|
||||||
@@ -295,7 +304,9 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
cls.errorss = errorss
|
cls.errorss = errorss
|
||||||
def errors(self, where = unicode()):
|
def errors(self, where = unicode()):
|
||||||
errs = []
|
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))
|
errs.extend(errors(self, where))
|
||||||
if hasattr(self, 'errors_hook'):
|
if hasattr(self, 'errors_hook'):
|
||||||
errs.extend(self.errors_hook(where))
|
errs.extend(self.errors_hook(where))
|
||||||
@@ -304,7 +315,9 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
|
|
||||||
cls.formatters = formatters
|
cls.formatters = formatters
|
||||||
def format(self, f, errs):
|
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)
|
formatter(self, f, errs)
|
||||||
cls.format = format
|
cls.format = format
|
||||||
def print_text(self, file = sys.stdout):
|
def print_text(self, file = sys.stdout):
|
||||||
|
|||||||
Reference in New Issue
Block a user