From 2a82cc7ebba79d46a442d8739196a21beaa9143b Mon Sep 17 00:00:00 2001 From: Simon Cadman Date: Sat, 1 Dec 2012 01:29:36 +0000 Subject: [PATCH] More @properties removed for older python support --- oauth2client/appengine.py | 3 ++- oauth2client/client.py | 16 +++++++++------- oauth2client/crypt.py | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/oauth2client/appengine.py b/oauth2client/appengine.py index b484c1e..b2dfd7d 100644 --- a/oauth2client/appengine.py +++ b/oauth2client/appengine.py @@ -78,11 +78,12 @@ def __init__(self, scope, **kwargs): None, None) - @classmethod def from_json(cls, json): data = simplejson.loads(json) return AppAssertionCredentials(data['scope']) + from_json = classmethod(from_json) + def _refresh(self, http_request): """Refreshes the access_token. diff --git a/oauth2client/client.py b/oauth2client/client.py index d8eaf69..3eef84f 100644 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -177,7 +177,6 @@ def to_json(self): """ return self._to_json(Credentials.NON_SERIALIZED_MEMBERS) - @classmethod def new_from_json(cls, s): """Utility class method to instantiate a Credentials subclass from a JSON representation produced by to_json(). @@ -204,7 +203,8 @@ def new_from_json(cls, s): from_json = getattr(kls, 'from_json') return from_json(s) - @classmethod + new_from_json = classmethod(new_from_json) + def from_json(cls, s): """Instantiate a Credentials object from a JSON description of it. @@ -218,6 +218,8 @@ def from_json(cls, s): """ return Credentials() + from_json = classmethod(from_json) + class Flow(object): """Base class for all Flow objects.""" @@ -453,7 +455,6 @@ def apply(self, headers): def to_json(self): return self._to_json(Credentials.NON_SERIALIZED_MEMBERS) - @classmethod def from_json(cls, s): """Instantiate a Credentials object from a JSON description of it. The JSON should have been produced by calling .to_json() on the object. @@ -483,8 +484,9 @@ def from_json(cls, s): data.get('id_token', None)) retval.invalid = data['invalid'] return retval + + from_json = classmethod(from_json) - @property def access_token_expired(self): """True if the credential is expired or invalid. @@ -502,6 +504,7 @@ def access_token_expired(self): now, self.token_expiry) return True return False + access_token_expired = property(access_token_expired) def set_store(self, store): """Set the Storage for the credential. @@ -673,14 +676,13 @@ def __init__(self, access_token, user_agent): None, user_agent) - - @classmethod def from_json(cls, s): data = simplejson.loads(s) retval = AccessTokenCredentials( data['access_token'], data['user_agent']) return retval + from_json = classmethod(from_json) def _refresh(self, http_request): raise AccessTokenCredentialsError( @@ -789,7 +791,6 @@ def __init__(self, self.service_account_name = service_account_name self.kwargs = kwargs - @classmethod def from_json(cls, s): data = simplejson.loads(s) retval = SignedJwtAssertionCredentials( @@ -803,6 +804,7 @@ def from_json(cls, s): ) retval.invalid = data['invalid'] return retval + from_json = classmethod(from_json) def _generate_assertion(self): """Generate the assertion that will be used in the request.""" diff --git a/oauth2client/crypt.py b/oauth2client/crypt.py index a882d7d..6bd06ad 100644 --- a/oauth2client/crypt.py +++ b/oauth2client/crypt.py @@ -60,7 +60,6 @@ def verify(self, message, signature): except: return False - @staticmethod def from_string(key_pem, is_x509_cert): """Construct a Verified instance from a string. @@ -80,6 +79,7 @@ def from_string(key_pem, is_x509_cert): else: pubkey = crypto.load_privatekey(crypto.FILETYPE_PEM, key_pem) return Verifier(pubkey) + from_string = staticmethod(from_string) class Signer(object): @@ -104,7 +104,6 @@ def sign(self, message): """ return crypto.sign(self._key, message, 'sha256') - @staticmethod def from_string(key, password='notasecret'): """Construct a Signer instance from a string. @@ -120,6 +119,7 @@ def from_string(key, password='notasecret'): """ pkey = crypto.load_pkcs12(key, password).get_privatekey() return Signer(pkey) + from_string = staticmethod(from_string) def _urlsafe_b64encode(raw_bytes):