]> git.madduck.net Git - etc/taskwarrior.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Task: Make Task object non-iterable
authorTomas Babej <tomasbabej@gmail.com>
Sun, 28 Dec 2014 00:54:22 +0000 (01:54 +0100)
committerTomas Babej <tomasbabej@gmail.com>
Sun, 28 Dec 2014 00:54:22 +0000 (01:54 +0100)
tasklib/task.py

index 44c6965c1e3fdde7be836e48a4f8befb7f9a38c8..096f656d7d9e903ecebd3b6a2c36f58b568afb79 100644 (file)
@@ -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))