X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/549524410137e15cd2ffcb91937c04c18d996ef7..bd3efb6ceee683f9575fb40c4ec9cf730e894939:/tasklib/task.py diff --git a/tasklib/task.py b/tasklib/task.py index 44c6965..096f656 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -34,6 +34,14 @@ class TaskResource(object): self._original_data = data.copy() def __getitem__(self, key): + # This is a workaround to make TaskResource non-iterable + # over simple index-based iteration + try: + int(key) + raise StopIteration + except ValueError: + pass + hydrate_func = getattr(self, 'deserialize_{0}'.format(key), lambda x: x) return hydrate_func(self._data.get(key))