X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/d66fcc9dcef74ab7cafee718cbb9fa78fec92d03..ff666e5453d71418ca45ee0542a82e2c58ef8442:/tasklib/serializing.py diff --git a/tasklib/serializing.py b/tasklib/serializing.py index ee04d38..767f7df 100644 --- a/tasklib/serializing.py +++ b/tasklib/serializing.py @@ -1,4 +1,5 @@ import datetime +import importlib import json import pytz import six @@ -7,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 @@ -164,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): @@ -201,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) @@ -230,5 +236,3 @@ class SerializingObject(object): "not: {}".format(value)) return value - -