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 def note( doc_str ):
00023 def p_doc( method ):
00024 method.__note__ = doc_str
00025 return method
00026 return p_doc
00027
00028 class Profileable( object ):
00029 Profiles = {}
00030
00031 def __new__(cls,name,bases,dict):
00032
00033 methods_dict = cls.get_methods_dict(dict)
00034
00035 new_class = type(name,bases,dict)
00036
00037 cls.Profiles[name] = (new_class,methods_dict)
00038
00039 return new_class
00040
00041
00042 @classmethod
00043 def get_methods_dict(cls,dict):
00044
00045 md = {}
00046 for key,val in dict.iteritems():
00047 if hasattr(val, "__note__"):
00048 doc_str = getattr(val, "__note__")
00049 md[key] = doc_str
00050
00051 return md