diff options
author | Mark Adams <mark@markadams.me> | 2015-04-12 13:27:11 -0500 |
---|---|---|
committer | Mark Adams <mark@markadams.me> | 2015-04-12 13:29:26 -0500 |
commit | a39b62eacc404f78094a5dfdf3b2e7113eea2f11 (patch) | |
tree | af67b7cc14ba53bbd348a2997e1a906803473dbf /jwt/utils.py | |
parent | 67de95326a8599d105e5c0b2b5b7a6aaa42c0161 (diff) | |
download | pyjwt-a39b62eacc404f78094a5dfdf3b2e7113eea2f11.tar.gz |
Created merge_dict utility function
Diffstat (limited to 'jwt/utils.py')
-rw-r--r-- | jwt/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/jwt/utils.py b/jwt/utils.py index e6c1ef3..bb7b3a3 100644 --- a/jwt/utils.py +++ b/jwt/utils.py @@ -12,3 +12,16 @@ def base64url_decode(input): def base64url_encode(input): return base64.urlsafe_b64encode(input).replace(b'=', b'') + + +def merge_dict(original, updates): + if not updates: + return original + + try: + merged_options = original.copy() + merged_options.update(updates) + except (AttributeError, ValueError) as e: + raise TypeError('original and updates must be a dictionary: %s' % e) + + return merged_options |