X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/f2d008def446626c071a9ceb2c80acb74d477cd0..dd44e7a4b6a175a6d88d16ccb2bd6ca05f6d9dc5:/tasklib/serializing.py?ds=inline diff --git a/tasklib/serializing.py b/tasklib/serializing.py index e980c58..767f7df 100644 --- a/tasklib/serializing.py +++ b/tasklib/serializing.py @@ -1,3 +1,5 @@ +import datetime +import importlib import json import pytz import six @@ -6,6 +8,7 @@ import tzlocal DATE_FORMAT = '%Y%m%dT%H%M%SZ' local_zone = tzlocal.get_localzone() + class SerializingObject(object): """ Common ancestor for TaskResource & TaskWarriorFilter, since they both @@ -163,6 +166,8 @@ class SerializingObject(object): return serialized_annotations if serialized_annotations else '' def deserialize_annotations(self, data): + task_module = importlib.import_module('tasklib.task') + TaskAnnotation = getattr(task_module, 'TaskAnnotation') return [TaskAnnotation(self, d) for d in data] if data else [] def serialize_tags(self, tags): @@ -200,8 +205,10 @@ class SerializingObject(object): localized datetime -> localized datetime (no conversion) """ - if (isinstance(value, datetime.date) - and not isinstance(value, datetime.datetime)): + if ( + isinstance(value, datetime.date) + and not isinstance(value, datetime.datetime) + ): # Convert to local midnight value_full = datetime.datetime.combine(value, datetime.time.min) localized = local_zone.localize(value_full) @@ -229,5 +236,3 @@ class SerializingObject(object): "not: {}".format(value)) return value - -