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
00022 class SU_ScalarMethods( object ):
00023
00024
00025 def __init__(self, cmd):
00026
00027 if not hasattr(self, cmd):
00028 name = self.__class__.__name__
00029 raise TypeError('No Scalar command "%s" in %s ' %(cmd,name) )
00030 self._command_name = cmd
00031
00032 def __call__(self, container, scalar, *args, **kw):
00033 '''
00034 only non classmethod calls methoc given by self._command_name
00035 '''
00036 if not hasattr(self, "_command_name"):
00037 raise AttributeError("scalar class not initialized")
00038
00039 cmd = self._command_name
00040 attr = getattr( self, cmd )
00041 attr( container, scalar, *args, **kw )
00042