_JSON_INDENT = 2
-_RE_EOLSP = re.compile('[ \t]+$', re.MULTILINE)
+_RE_EOLSP = re.compile("[ \t]+$", re.MULTILINE)
def _GetJsonDumpers(_encoder_class=simplejson.JSONEncoder):
fn = _DumpJson
txt = _RE_EOLSP.sub("", fn(data))
- if not txt.endswith('\n'):
- txt += '\n'
+ if not txt.endswith("\n"):
+ txt += "\n"
return txt
"""
txt = DumpJson(data, indent=False)
if salt is None:
- salt = ''
+ salt = ""
signed_dict = {
- 'msg': txt,
- 'salt': salt,
+ "msg": txt,
+ "salt": salt,
}
if key_selector:
"""
signed_dict = LoadJson(txt)
if not isinstance(signed_dict, dict):
- raise errors.SignatureError('Invalid external message')
+ raise errors.SignatureError("Invalid external message")
try:
- msg = signed_dict['msg']
- salt = signed_dict['salt']
- hmac_sign = signed_dict['hmac']
+ msg = signed_dict["msg"]
+ salt = signed_dict["salt"]
+ hmac_sign = signed_dict["hmac"]
except KeyError:
- raise errors.SignatureError('Invalid external message')
+ raise errors.SignatureError("Invalid external message")
if callable(key):
# pylint: disable-msg=E1103
if not utils.VerifySha1Hmac(hmac_key, msg, hmac_sign,
salt=salt + key_selector):
- raise errors.SignatureError('Invalid Signature')
+ raise errors.SignatureError("Invalid Signature")
return LoadJson(msg), salt