<s> """<STR_LIT>""" <EOL> __author__ = "<STR_LIT>" <EOL> __revision__ = "<STR_LIT>" [ <NUM_LIT:11> : - <NUM_LIT:2> ] <EOL> from Cheetah . Utils . Misc import useOrRaise <EOL> class NonNumericInputError ( ValueError ) : pass <EOL> class _Converter : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , func , default , error ) : <EOL> self . name = name <EOL> self . func = func <EOL> self . default = default <EOL> self . error = error <EOL> def _lookup ( name , func , multi , converters ) : <EOL> """<STR_LIT>""" <EOL> colon = name . find ( '<STR_LIT::>' ) <EOL> if colon != - <NUM_LIT:1> : <EOL> longName = name <EOL> shortName , ext = name [ : colon ] , name [ colon + <NUM_LIT:1> : ] <EOL> else : <EOL> longName = shortName = name <EOL> ext = '<STR_LIT>' <EOL> if longName != shortName : <EOL> values = func ( longName , None ) or func ( shortName , None ) <EOL> else : <EOL> values = func ( shortName , None ) <EOL> if values is None : <EOL> values = [ ] <EOL> elif isinstance ( values , str ) : <EOL> values = [ values ] <EOL> try : <EOL> converter = converters [ ext ] <EOL> except KeyError : <EOL> fmt = "<STR_LIT>" <EOL> tup = ( ext , longName ) <EOL> raise TypeError ( fmt % tup ) <EOL> if converter . func is not None : <EOL> tmp = values [ : ] <EOL> values = [ ] <EOL> for elm in tmp : <EOL> try : <EOL> elm = converter . func ( elm ) <EOL> except ( TypeError , ValueError ) : <EOL> tup = converter . name , elm <EOL> errmsg = "<STR_LIT>" % tup <EOL> elm = useOrRaise ( converter . error , errmsg ) <EOL> values . append ( elm ) <EOL> if multi : <EOL> return shortName , values <EOL> if len ( values ) == <NUM_LIT:0> : <EOL> return shortName , useOrRaise ( converter . default ) <EOL> return shortName , values [ <NUM_LIT:0> ] </s>
