From 96a7f5acd43e82c7da98da15219349282d9c2a6d Mon Sep 17 00:00:00 2001 From: RTB Date: Sun, 8 Jun 2014 18:52:29 +0200 Subject: [PATCH] added get_section function to grab sections from sources.cfg --- utils/configurator.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/configurator.py b/utils/configurator.py index 90e0320..db6c111 100644 --- a/utils/configurator.py +++ b/utils/configurator.py @@ -1,6 +1,6 @@ from scrapy import log from scrapy.utils.project import get_project_settings - +import ConfigParser class Configurator: """ @@ -47,3 +47,13 @@ class Configurator: log.start(logstdout=False, loglevel=log.DEBUG) else: log.start(logstdout=True, loglevel=log.WARNING) + + def get_section(self, config, sourcename): + section = dict() + if config.has_section(sourcename): + section = dict(config.items(sourcename)) + if 'reliability' not in section: + log.msg('Reliability not set for %s' % sourcename, + level=log.WARNING) + section['reliability'] = '' + return section