Archived
1
0

Create the Source configuration if not yet existent

This commit is contained in:
Jip J. Dekker 2014-06-21 01:05:07 +02:00
parent 17ce11e530
commit b0faf80918

View File

@ -1,5 +1,6 @@
import ConfigParser
import os
import shutil
from scrapy.utils.project import get_project_settings
@ -70,6 +71,11 @@ class Configurator:
current_dir = os.path.dirname(os.path.abspath(__file__))
config_path = current_dir + '/../sources.cfg'
# [TODO]: location of sources.cfg should be softcoded eventually
if not os.path.isfile(config_path):
try:
shutil.copyfile(os.path.dirname(os.path.abspath(__file__)) + "/../sources.cfg.sample", config_path)
except IOError:
print "WARNING: Source configuration couldn't be found and couldn't be created."
config = ConfigParser.ConfigParser()
config.read(config_path)
return config