]>
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:
summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1d0bf81 )
def _load_data(self, data):
self._data = data
# We need to use a copy for original data, so that changes
def _load_data(self, data):
self._data = data
# We need to use a copy for original data, so that changes
+ # are not propagated. Shallow copy is alright, since data dict uses only
+ # primitive data types
self._original_data = data.copy()
self._original_data = data.copy()
+ def _update_data(self, data, update_original=False):
+ """
+ Low level update of the internal _data dict. Data which are coming as
+ updates should already be serialized. If update_original is True, the
+ original_data dict is updated as well.
+ """
+
+ self._data.update(data)
+
+ if update_original:
+ self._original_data.update(data)
+
def __getitem__(self, key):
# This is a workaround to make TaskResource non-iterable
# over simple index-based iteration
def __getitem__(self, key):
# This is a workaround to make TaskResource non-iterable
# over simple index-based iteration
- def __init__(self, warrior, data={}, **kwargs):
+ def __init__(self, warrior, **kwargs):
self.warrior = warrior
# We serialize the data in kwargs so that users of the library
self.warrior = warrior
# We serialize the data in kwargs so that users of the library
self._load_data(dict((key, self._serialize(key, value))
for (key, value) in six.iteritems(kwargs)))
self._load_data(dict((key, self._serialize(key, value))
for (key, value) in six.iteritems(kwargs)))
- # We keep data for backwards compatibility
- # TODO: Should we keep this using unserialized access to _data dict?
- self._data.update(data)
- self._original_data.update(data)
-
def __unicode__(self):
return self['description']
def __unicode__(self):
return self['description']
if only_fields:
to_update = dict(
[(k, new_data.get(k)) for k in only_fields])
if only_fields:
to_update = dict(
[(k, new_data.get(k)) for k in only_fields])
- self._data.update(to_update)
- self._original_data.update(to_update)
+ self._update_data(to_update, update_original=True)
- self._data = new_data
- # We need to create a clone for original_data though
- # Shallow copy is alright, since data dict uses only
- # primitive data types
- self._original_data = new_data.copy()
+ self._load_data(new_data)
class TaskFilter(object):
class TaskFilter(object):
if line:
data = line.strip(',')
try:
if line:
data = line.strip(',')
try:
- tasks.append(Task(self, json.loads(data)))
+ filtered_task = Task(self)
+ filtered_task._load_data(json.loads(data))
+ tasks.append(filtered_task)
except ValueError:
raise TaskWarriorException('Invalid JSON: %s' % data)
return tasks
except ValueError:
raise TaskWarriorException('Invalid JSON: %s' % data)
return tasks