From: Tomas Babej Date: Sat, 26 Dec 2015 15:53:38 +0000 (+0100) Subject: SerializingObject: (De)Serialize the parent attribute X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/829273c7a8e6cfc0b20b3f817e6e34f76a4ee35d?ds=sidebyside;hp=--cc SerializingObject: (De)Serialize the parent attribute --- 829273c7a8e6cfc0b20b3f817e6e34f76a4ee35d diff --git a/tasklib/serializing.py b/tasklib/serializing.py index ff9b977..8cdeaf2 100644 --- a/tasklib/serializing.py +++ b/tasklib/serializing.py @@ -6,7 +6,7 @@ import six import tzlocal -from .lazy import LazyUUIDTaskSet +from .lazy import LazyUUIDTaskSet, LazyUUIDTask DATE_FORMAT = '%Y%m%dT%H%M%SZ' local_zone = tzlocal.get_localzone() @@ -181,6 +181,12 @@ class SerializingObject(object): return set(tags.split(',')) if tags else set() return set(tags or []) + def serialize_parent(self, parent): + return parent['uuid'] if parent else '' + + def deserialize_parent(self, uuid): + return LazyUUIDTask(self.backend, uuid) if uuid else None + def serialize_depends(self, value): # Return the list of uuids value = value if value is not None else set()