def handle_unauthenticated(func):
 @functools.wraps(func)
 def wrapped(self, *args, **kwargs):
  try:
   return func(self, *args, **kwargs)
  except exception.NotAuthenticated:
   self._authenticate(force_reauth=True)
   return func(self, *args, **kwargs)
 return wrapped

def handle_unauthenticated ( func ) : @ functools . wraps ( func ) def wrapped ( self , * args , ** kwargs ) : try : return func ( self , * args , ** kwargs ) except exception . NotAuthenticated : self . _authenticate ( force_reauth = True ) return func ( self , * args , ** kwargs ) return wrapped
wrap a function to re-authenticate and retry .