From e3528a8f36c6ee40dafd90d6cf29b2e079ac77a3 Mon Sep 17 00:00:00 2001 From: pictuga Date: Wed, 18 Mar 2020 16:31:36 +0100 Subject: [PATCH] feeds: use FeddJSON for .tojson() Clean up related code --- morss/feeds.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index f4c3195..ce00965 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -20,12 +20,6 @@ from wheezy.template.ext.core import CoreExtension json.encoder.c_make_encoder = None -try: - from collections import OrderedDict -except ImportError: - # python < 2.7 - from ordereddict import OrderedDict - try: from StringIO import StringIO from urllib2 import urlopen @@ -86,8 +80,7 @@ class ParserBase(object): pass def tojson(self, indent=None): - # TODO temporary - return json.dumps(OrderedDict(self.iterdic()), indent=indent) + return self.convert(FeedJSON).tostring() def tocsv(self): # TODO temporary @@ -126,17 +119,6 @@ class ParserBase(object): return target - def iterdic(self): - for element in self.dic: - value = getattr(self, element) - - if element == 'items': - value = [OrderedDict(x.iterdic()) for x in value] - elif isinstance(value, datetime): - value = value.isoformat() - - yield element, value - # RULE-BASED FUNCTIONS def rule_search(self, rule):