def must_be(_type):
 def _must_be(func):
  @functools.wraps(func)
  def wrapped(self, *args, **kwargs):
   if (not (self.kind == _type)):
    raise ValueError(u'This instance is not a {}'.format(_type))
   return func(self, *args, **kwargs)
  return wrapped
 return _must_be

def must_be ( _type ) : def _must_be ( func ) : @ functools . wraps ( func ) def wrapped ( self , * args , ** kwargs ) : if ( not ( self . kind == _type ) ) : raise ValueError ( u'This instance is not a {}' . format ( _type ) ) return func ( self , * args , ** kwargs ) return wrapped return _must_be
a small decorator factory for osfstoragefilenode .