each source now receives a configuration dictionary
This commit is contained in:
parent
fb3c760249
commit
ff3b81b813
@ -20,8 +20,8 @@ class ChemSpider(Source):
|
||||
somewhere.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
Source.__init__(self)
|
||||
def __init__(self, config):
|
||||
Source.__init__(self, config)
|
||||
|
||||
website = 'http://www.chemspider.com/*'
|
||||
|
||||
|
@ -24,8 +24,8 @@ class NIST(Source):
|
||||
|
||||
ignore_list = set()
|
||||
|
||||
def __init__(self):
|
||||
Source.__init__(self)
|
||||
def __init__(self, config):
|
||||
Source.__init__(self, config)
|
||||
|
||||
def parse(self, response):
|
||||
sel = Selector(response)
|
||||
|
@ -19,8 +19,8 @@ class WikipediaParser(Source):
|
||||
__spider = None
|
||||
searched_compounds = []
|
||||
|
||||
def __init__(self):
|
||||
Source.__init__(self)
|
||||
def __init__(self, config):
|
||||
Source.__init__(self, config)
|
||||
|
||||
def parse(self, response):
|
||||
""" Distributes the above described behaviour """
|
||||
|
@ -6,7 +6,7 @@ class Source:
|
||||
website = "http://something/*" # Regex of URI's the source is able to parse
|
||||
_spider = None
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
"""
|
||||
Initiation of a new Source
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ class SourceLoader:
|
||||
sourcecfg = dict()
|
||||
if config.has_section(cls.__name__):
|
||||
sourcecfg = dict(config.items(cls.__name__))
|
||||
self.sources.append(cls()) # [review] - Would we ever need arguments for the parsers?
|
||||
self.sources.append(cls(sourcecfg))
|
||||
known_parser.add(cls)
|
||||
|
||||
def include(self, source_names):
|
||||
|
Reference in New Issue
Block a user