summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2014-06-15 14:34:22 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2014-06-15 16:46:12 +0300
commit7fd9d4bdbc31e8daea240229f0385109b58659a0 (patch)
tree86ddc8c6e3266a457fcfde8115e43102f1a86885
parent13f52888dbdb740f921afb7f07d3cdc3cfc94b15 (diff)
downloadapscheduler-7fd9d4bdbc31e8daea240229f0385109b58659a0.tar.gz
Added the prefix option to configure()
-rw-r--r--apscheduler/schedulers/base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/apscheduler/schedulers/base.py b/apscheduler/schedulers/base.py
index a467f31..eb2b5b0 100644
--- a/apscheduler/schedulers/base.py
+++ b/apscheduler/schedulers/base.py
@@ -56,20 +56,25 @@ class BaseScheduler(six.with_metaclass(ABCMeta)):
self._pending_jobs = []
self.configure(gconfig, **options)
- def configure(self, gconfig={}, **options):
+ def configure(self, gconfig={}, prefix='apscheduler.', **options):
"""
Reconfigures the scheduler with the given options. Can only be done when the scheduler isn't running.
:param dict gconfig: a "global" configuration dictionary whose values can be overridden by keyword arguments to
this method
+ :param str|unicode prefix: pick only those keys from ``gconfig`` that are prefixed with this string
+ (pass an empty string or ``None`` to use all keys)
:raises SchedulerAlreadyRunningError: if the scheduler is already running
"""
if self.running:
raise SchedulerAlreadyRunningError
+ # If a non-empty prefix was given,
+ if prefix:
+ gconfig = dict((key[11:], value) for key, value in six.iteritems(gconfig) if key.startswith(prefix))
+
# Create a structure from the dotted options (e.g. "a.b.c = d" -> {'a': {'b': {'c': 'd'}}})
- gconfig = dict((key[11:], value) for key, value in six.iteritems(gconfig) if key.startswith('apscheduler.'))
config = {}
for key, value in six.iteritems(gconfig):
parts = key.split('.', 1)