From f26bb88fa267f52af007bb781f53c9e059d4d560 Mon Sep 17 00:00:00 2001 From: David Kane Date: Fri, 24 Jan 2020 11:40:30 +0000 Subject: [PATCH] switch objects back on --- findthatcharity_import/spiders/ccew.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/findthatcharity_import/spiders/ccew.py b/findthatcharity_import/spiders/ccew.py index c117cc0..3fcbcb0 100644 --- a/findthatcharity_import/spiders/ccew.py +++ b/findthatcharity_import/spiders/ccew.py @@ -105,12 +105,12 @@ class CCEWSpider(BaseScraper): "welsh", # char(1) Flag: Y or blank "master", # integer may be blank. If aootype=D then holds continent; if aootype=B then holds GLA/met county ], - # 'extract_objects': [ - # "regno", # integer egistered number of a charity - # "subno", # integer ubsidiary number of a charity (may be 0 for main/group charity) - # "seqno", # char(4) equence number (in practice 0-20) - # "object", # varchar(255) Description of objects of a charity - # ], + 'extract_objects': [ + "regno", # integer registered number of a charity + "subno", # integer subsidiary number of a charity (may be 0 for main/group charity) + "seqno", # char(4) sequence number (in practice 0-20) + "object", # varchar(255) Description of objects of a charity + ], } def start_requests(self): @@ -183,10 +183,6 @@ def process_bcp(self, bcpfile, filename): if not row.get("regno"): continue charity = self.get_charity(row['regno']) - if not charity: - charity = { - f: [] for f in self.ccew_files.keys() - } if (filename in ["extract_main_charity", "extract_charity"] and row.get("subno", '0') == '0'): for field in row: charity[field] = row[field] @@ -202,8 +198,8 @@ def initialise_charities(self): def get_charity(self, regno): if self.redis: charity = self.redis.hget('charities', regno) - return pickle.loads(charity) if charity else charity - return self.charities.get(regno) + return pickle.loads(charity) if charity else {f: [] for f in self.ccew_files.keys()} + return self.charities.get(regno, {f: [] for f in self.ccew_files.keys()}) def set_charity(self, regno, charity): if self.redis: