def get_auth_args(self, cred, challenge):
        """Generate authentication arguments using given credentials
        and challenge.

        @type cred: DigestAuthCredentials

        @type challenge: None or str

        @rtype: dict
        """

        base, opts = None, None
        args = {}

        if challenge:
            base, opts = parse_description_string(challenge,
                                                  authmod=self.authmod)

        if not base:
            if not challenge:
                # assuming initial connect - args based on possible cred state
                return self.initial_args(args, cred, challenge)

            raise UnauthorizedLogin('could not authenticate: %s' %
                                    (challenge,))
        else:
            if self.authmod:
                args.update(authmod=self.authmod)

            code_str = base.get('code')
            if code_str:
                code = code_str.split(None, 1)[0]
                handler_m = getattr(self, code % 'code_%s', None)
                if handler_m is None:
                    return self.unhandled_code(code_str, cred, challenge)
                else:
                    return handler_m(args, cred, code_str, challenge)
            elif opts and opts.has_key('reason'):
                reason = opts['reason']
                handler_m = getattr(self, 'reason_%s' % (reason,))

                if handler_m is None:
                    return self.unhandled_reason(reason, cred, challenge)
                else:
                    return handler_m(args, cred, opts, challenge)
            else:
                raise AuthProtocolContractError("Don't know what to do: %r" %
                                                (challenge,))
dataset/ETHPy150Open arkadini/twimp/twimp/auth/base.py/Authenticator.get_auth_args/swapped operands of `%`