Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] turn the config into a component of the app #186

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scrapyd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
from os.path import expanduser

from zope.interface import implements
from scrapy.utils.conf import closest_scrapy_cfg

from scrapyd.interfaces import IConfig

class Config(object):
"""A ConfigParser wrapper to support defaults when calling instance
methods, and also tied to a single section"""
implements(IConfig)

SECTION = 'scrapyd'

Expand Down
20 changes: 20 additions & 0 deletions scrapyd/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,23 @@ def get_environment(message, slot):
`message` is the message received from the IPoller.next() method
`slot` is the Launcher slot where the process will be running.
"""


class IConfig(Interface):
"""A component to provide access to the active configuration"""

def get(option, default=None):
"""Return the specified `option` from the config"""

def getint(option, default=None):
"""Return the specified integer `option` from the config"""

def getfloat(option, default=None):
"""Return the specified float `option` from the config"""

def getboolean(option, default=None):
"""Return the specified boolean `option` from the config"""

def items(section, default=None):
"""Return a list of (name, value) pairs
for each `option` in the scrapyd section"""