A web scraper build to search specific information for a given compound (and its pseudonyms)

Refractoring double code

+3 -12
-4
FourmiCrawler/sources/ChemSpider.py
··· 28 28 29 29 def __init__(self, config=None): 30 30 Source.__init__(self, config) 31 - if self.cfg is None: 32 - self.cfg = {} 33 - else: 34 - self.cfg = config 35 31 self.ignore_list = [] 36 32 if 'token' not in self.cfg or self.cfg['token'] == '': 37 33 log.msg('ChemSpider token not set or empty, search/MassSpec API '
-4
FourmiCrawler/sources/NIST.py
··· 25 25 def __init__(self, config=None): 26 26 Source.__init__(self, config) 27 27 self.ignore_list = set() 28 - if config is None: 29 - self.cfg = {} 30 - else: 31 - self.cfg = config 32 28 33 29 def parse(self, response): 34 30 sel = Selector(response)
-4
FourmiCrawler/sources/WikipediaParser.py
··· 21 21 22 22 def __init__(self, config=None): 23 23 Source.__init__(self, config) 24 - if config is None: 25 - self.cfg = {} 26 - else: 27 - self.cfg = config 28 24 29 25 def parse(self, response): 30 26 """
+3
FourmiCrawler/sources/source.py
··· 10 10 """ 11 11 Initiation of a new Source 12 12 """ 13 + self.cfg = {} 14 + if config is not None: 15 + self.cfg = config 13 16 pass 14 17 15 18 def parse(self, response):