00001 __copyright__ = """
00002 Copyright 2008 Sean Ross-Ross
00003 """
00004 __license__ = """
00005 This file is part of SLIMpy .
00006
00007 SLIMpy is free software: you can redistribute it and/or modify
00008 it under the terms of the GNU Lesser General Public License as published by
00009 the Free Software Foundation, either version 3 of the License, or
00010 (at your option) any later version.
00011
00012 SLIMpy is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 GNU Lesser General Public License for more details.
00016
00017 You should have received a copy of the GNU Lesser General Public License
00018 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00019 """
00020
00021 from slimpy_base.Core.Builders.BuilderBase import BuilderBase
00022
00023
00024 class CompoundBuilder( BuilderBase):
00025
00026 def __init__(self , builders):
00027
00028 msg = "parameter 'builders' must be a list of builder instances"
00029 if not isinstance(builders, (list,tuple) ):
00030 raise TypeError(msg)
00031
00032 is_builder = lambda Bool,builder: Bool or not isinstance( builder, BuilderBase )
00033
00034 one_non_builder = reduce(is_builder, builders, False )
00035
00036 if len(builders) is not 0 or one_non_builder:
00037 raise TypeError(msg)
00038 self.builers = builders
00039
00040 def get_builders(self):
00041 return self._builers
00042
00043 def set_builders(self,builders):
00044 self._builers = builders
00045
00046 builders = property( get_builders, set_builders )
00047
00048 def build(self,graph,*targets,**kw):
00049
00050 for builder in self.builders:
00051 graph = builder.build(graph,*targets,**kw)
00052
00053 return graph
00054
00055