def add_type(type_, func=None):
 def _check_type(type_):
  if (not (isinstance(type_, python.class_types) or hasattr(type_, '__call__'))):
   raise TypeError((('Unable to add ' % ' as a custom type (expected a class or callable)') % (type_,)))
 if isinstance(type_, list):
  type_ = tuple(type_)
 if (type_ in TYPE_MAP):
  raise KeyError(('Type %r already exists' % (type_,)))
 if isinstance(type_, types.TupleType):
  for x in type_:
   _check_type(x)
 else:
  _check_type(type_)
 TYPE_MAP[type_] = func

def add_type ( type_ , func = None ) : def _check_type ( type_ ) : if ( not ( isinstance ( type_ , python . class_types ) or hasattr ( type_ , '__call__' ) ) ) : raise TypeError ( ( ( 'Unable to add ' % ' as a custom type (expected a class or callable)' ) % ( type_ , ) ) ) if isinstance ( type_ , list ) : type_ = tuple ( type_ ) if ( type_ in TYPE_MAP ) : raise KeyError ( ( 'Type %r already exists' % ( type_ , ) ) ) if isinstance ( type_ , types . TupleType ) : for x in type_ : _check_type ( x ) else : _check_type ( type_ ) TYPE_MAP [ type_ ] = func
add a mapping between a type and an extension .