def validate_target(func, *args, **kwargs):
 def inner(self, *args, **kwargs):
  target_id = None
  if (('target_id' in kwargs) and (kwargs['target_id'] != None)):
   target_id = kwargs['target_id']
  else:
   target_id = 0
  if (not self.target_is_valid(target_id)):
   raise NoSuchTargetException()
  return func(self, *args, **kwargs)
 return inner

def validate_target ( func , * args , ** kwargs ) : def inner ( self , * args , ** kwargs ) : target_id = None if ( ( 'target_id' in kwargs ) and ( kwargs [ 'target_id' ] != None ) ) : target_id = kwargs [ 'target_id' ] else : target_id = 0 if ( not self . target_is_valid ( target_id ) ) : raise NoSuchTargetException ( ) return func ( self , * args , ** kwargs ) return inner
a decorator that ensures that the specified target_id exists and is valid .