diff options
author | Eugene Eeo <xe0jun@hotmail.com> | 2014-12-13 15:21:21 +0800 |
---|---|---|
committer | Eugene Eeo <xe0jun@hotmail.com> | 2014-12-13 15:21:21 +0800 |
commit | 835e9b5d276cd7cf6fdc399a820ef210d805b0bd (patch) | |
tree | dc3356dc4487b94b89dba4e9f9a8145ffb937578 | |
parent | fbd9790a82b4391dea93e778be091870375762c8 (diff) | |
download | uritemplates-835e9b5d276cd7cf6fdc399a820ef210d805b0bd.tar.gz |
minor refactor of code
-rw-r--r-- | uritemplate/template.py | 10 | ||||
-rw-r--r-- | uritemplate/variable.py | 11 |
2 files changed, 8 insertions, 13 deletions
diff --git a/uritemplate/template.py b/uritemplate/template.py index 239c1b6..0d45214 100644 --- a/uritemplate/template.py +++ b/uritemplate/template.py @@ -121,10 +121,9 @@ class URITemplate(object): ``val2`` will be used instead of ``val1``. """ - var_dict = var_dict or {} - var_dict.update(kwargs) + kwargs.update(var_dict or {}) - return self._expand(var_dict, False) + return self._expand(kwargs, False) def partial(self, var_dict=None, **kwargs): """Partially expand the template with the given parameters. @@ -142,7 +141,6 @@ class URITemplate(object): t.partial() # => URITemplate('https://api.github.com{/end}') """ - var_dict = var_dict or {} - var_dict.update(kwargs) + kwargs.update(var_dict or {}) - return URITemplate(self._expand(var_dict, True)) + return URITemplate(self._expand(kwargs, True)) diff --git a/uritemplate/variable.py b/uritemplate/variable.py index 38b80c0..077ad21 100644 --- a/uritemplate/variable.py +++ b/uritemplate/variable.py @@ -335,12 +335,10 @@ class URIVariable(object): if expanded is not None: return_values.append(expanded) + value = '' if return_values: - return { - self.original: self.start + self.join_str.join(return_values) - } - - return {self.original: ''} + value = self.start + self.join_str.join(return_values) + return {self.original: value} def is_list_of_tuples(value): @@ -349,10 +347,9 @@ def is_list_of_tuples(value): try: dict(value) + return True, value except: return False, None - else: - return True, value def list_test(value): |