def handle(*codes, **kwargs):
        """
        Method decorator: if a given status code is received, re-authenticate and try again.

        Args:
            codes (int list): status codes to respond to
            regToken (bool): whether to try retrieving a new token on error

        Returns:
            method: decorator function, ready to apply to other methods
        """
        regToken = kwargs.get("regToken", False)
        subscribe = kwargs.get("subscribe")

        def decorator(fn):
            @functools.wraps(fn)
            def wrapper(self, *args, **kwargs):
                try:
                    return fn(self, *args, **kwargs)
                except SkypeApiException as e:
                    if isinstance(e.args[1], requests.Response) and e.args[1].status_code in codes:
                        conn = self if isinstance(self, SkypeConnection) else self.conn
                        if regToken:
                            conn.getRegToken()
                        if subscribe:
                            conn.endpoints[subscribe].subscribe()
                        return fn(self, *args, **kwargs)
                    raise
            return wrapper

        return decorator
def handle(*codes, **kwargs):
        """
        Method decorator: if a given status code is received, re-authenticate and try again.

        Args:
            codes (int list): status codes to respond to
            regToken (bool): whether to try retrieving a new token on error

        Returns:
            method: decorator function, ready to apply to other methods
        """
        regToken = kwargs.get("regToken", False)
        subscribe = kwargs.get("subscribe")

        def decorator(fn):
            @functools.wraps(fn)
            def wrapper(self, *args, **kwargs):
                try:
                    return fn(self, *args, **kwargs)
                except SkypeApiException as e:
                    if isinstance(e.args[1], requests.Response) and e.args[1].status_code in codes:
                        conn = self if isinstance(self, SkypeConnection) else self.conn
                        if regToken:
                            conn.getRegToken()
                        if subscribe:
                            conn.endpoints[subscribe].subscribe()
                        return fn(self, *args, **kwargs)
                    raise
            return wrapper

        return decorator
def handle ( * codes , * * kwargs ) : regToken = kwargs . get ( "regToken" , False ) subscribe = kwargs . get ( "subscribe" ) def decorator ( fn ) : @ functools . wraps ( fn ) def wrapper ( self , * args , * * kwargs ) : try : return fn ( self , * args , * * kwargs ) except SkypeApiException as e : if isinstance ( e . args [ 1 ] , requests . Response ) and e . args [ 1 ] . status_code in codes : conn = self if isinstance ( self , SkypeConnection ) else self . conn if regToken : conn . getRegToken ( ) if subscribe : conn . endpoints [ subscribe ] . subscribe ( ) return fn ( self , * args , * * kwargs ) raise return wrapper return decorator
Method decorator: if a given status code is received, re-authenticate and try again.

        Args:
            codes (int list): status codes to respond to
            regToken (bool): whether to try retrieving a new token on error

        Returns:
            method: decorator function, ready to apply to other methods
Method decorator : if a given status code is received re - authenticate and try again .