Package grassyknoll :: Package lib :: Module Norman
[hide private]

Module Norman

source code

Norman likes things neat

XXX OH GOD NEED TESTS!
>>> pants=ObjectNorman()
>>> pants.sale_date=DateNorman()
>>> pants.size=IntegerNorman(optional=True)
>>> pants.color=UnicodeNorman()
>>> pants.constant=FunctionNorman(lambda x: u"CONSTANT", prohibited=True, filled=True)
>>> input=dict(sale_date='April 1, 2007', size='32', color='blue')
>>> bluejeans=pants(input)
>>> bluejeans is input
False
>>> bluejeans['size']
32
>>> bluejeans['color']
u'blue'
>>> bluejeans['sale_date']
datetime.date(2007, 4, 1)
>>> bluejeans['constant']
u'CONSTANT'


Classes [hide private]
  NormanError
error raised when a value cannot be normalized
  Norman
base class for Normans
  ObjectNorman
Norman that operates on dict or object.__dict__
  MultiValueNorman
wraps up another Norman, and returns a list of values
  FunctionNorman
Norman that calls a function with curried kwargs
  IdemNorman
a Norman that just returns whatever you pass it
  NoneNorman
normalizes to None
  BoolNorman
normalizes to boolean
  IntegerNorman
normalizes to an integer
  FloatNorman
normalizes to a float
  UnicodeNorman
Normalizes to unicode by decoding.
  StrNorman
Normalizes to str by encoding.
  MapNorman
Normalizes using a dict
  DateTimeNorman
Normalizes to a datetime.datetime
  DateNorman
Normalizes to datetime.date
  TimeNorman
Normalizes to datetime.time
Functions [hide private]
 
lowerString(f) source code
 
TimestampNorman(optional=False, filled=True, prohibited=True)
Norman that returns a current datetime.datetime
source code
 
EtagNorman(optional=False, filled=True, prohibited=True)
Norman that returns a reasonable value for use as an etag
source code