From d1aab99b80089382a533338b1d49d61cbe1d6c1a Mon Sep 17 00:00:00 2001 From: pictuga Date: Wed, 31 Oct 2018 22:15:34 +0100 Subject: [PATCH] feeds: replacement code for descriptors --- morss/feeds.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/morss/feeds.py b/morss/feeds.py index e2a6779..56d8c19 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -160,6 +160,25 @@ class FeedBase(object): if match is not None: return match.getparent().remove(match) + def from_bool(self, x): + return (x or '').lower() != 'false' + + def to_bool(self, x): + return 'true' if value else 'false' + + def from_time(self, x): + try: + return parse_time(x) + except ValueError: + return None + + def to_time(self, x): + try: + time = parse_time(value) + return time.strftime(instance.timeFormat) + except ValueError: + pass + def tostring(self, **k): """ Returns string using lxml. Arguments passed to tostring """ return etree.tostring(self.xml, **k)