<s> """<STR_LIT>""" <EOL> __version__ = "<STR_LIT>" <EOL> from . import util <EOL> import weakref <EOL> from copy import copy <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class StyleProperty ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , default , validator = None , doc = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . _default = None <EOL> self . _name = None <EOL> self . _owner = None <EOL> self . validator = validator <EOL> self . __doc__ = doc <EOL> self . default = default <EOL> @ property <EOL> def name ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _name <EOL> @ property <EOL> def owner ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _owner <EOL> @ property <EOL> def default ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _default <EOL> @ default . setter <EOL> def default ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . _default = self . validate ( value ) <EOL> def initialize ( self , instance , memberName , kwargs ) : <EOL> """<STR_LIT>""" <EOL> if memberName in kwargs : <EOL> value = kwargs . pop ( memberName ) <EOL> else : <EOL> value = copy ( self . default ) <EOL> setattr ( instance , memberName , value ) <EOL> def validate ( self , value ) : <EOL> """<STR_LIT>""" <EOL> if self . validator : <EOL> try : <EOL> result = self . validator ( value ) <EOL> return result <EOL> except Exception , e : <EOL> name = self . name <EOL> if self . owner : <EOL> name = "<STR_LIT>" % ( self . owner . __name__ , name ) <EOL> msg = "<STR_LIT>" % name <EOL> raise util . mergeExceptions ( e , msg ) <EOL> else : <EOL> return value <EOL> def __call__ ( self , value ) : <EOL> """<STR_LIT>""" <EOL> return self . validate ( value ) <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . owner : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , <EOL> self . owner . __name__ , <EOL> self . name ) <EOL> elif self . name : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . name ) <EOL> else : <EOL> return "<STR_LIT:%s>" % ( self . __class__ . __name__ ) <EOL> def __get__ ( self , instance , owner ) : <EOL> """<STR_LIT>""" <EOL> if instance : <EOL> return instance . __dict__ [ self . name ] <EOL> else : <EOL> return self <EOL> def __set__ ( self , instance , value ) : <EOL> """<STR_LIT>""" <EOL> instance . __dict__ [ self . name ] = self . validate ( value ) </s>
