X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/73cb96ecbbcaf43f05dc825a1017c2680b79f5a9..a8a458c71b1a1f6e23fb734da35c349b14f5c462:/tasklib/serializing.py diff --git a/tasklib/serializing.py b/tasklib/serializing.py index ed2881d..767f7df 100644 --- a/tasklib/serializing.py +++ b/tasklib/serializing.py @@ -1,3 +1,14 @@ +import datetime +import importlib +import json +import pytz +import six +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 @@ -155,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): @@ -192,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) @@ -221,5 +236,3 @@ class SerializingObject(object): "not: {}".format(value)) return value - -