Stripped whitespace from comma-separated values read from config file

This commit is contained in:
Vinay Sajip 2006-12-14 08:41:39 +00:00
parent 9e2423ae8f
commit 4d7ad63210
1 changed files with 5 additions and 4 deletions

View File

@ -110,7 +110,7 @@ def _create_formatters(cp):
flist = string.split(flist, ",") flist = string.split(flist, ",")
formatters = {} formatters = {}
for form in flist: for form in flist:
sectname = "formatter_%s" % form sectname = "formatter_%s" % string.strip(form)
opts = cp.options(sectname) opts = cp.options(sectname)
if "format" in opts: if "format" in opts:
fs = cp.get(sectname, "format", 1) fs = cp.get(sectname, "format", 1)
@ -139,7 +139,7 @@ def _install_handlers(cp, formatters):
handlers = {} handlers = {}
fixups = [] #for inter-handler references fixups = [] #for inter-handler references
for hand in hlist: for hand in hlist:
sectname = "handler_%s" % hand sectname = "handler_%s" % string.strip(hand)
klass = cp.get(sectname, "class") klass = cp.get(sectname, "class")
opts = cp.options(sectname) opts = cp.options(sectname)
if "formatter" in opts: if "formatter" in opts:
@ -176,6 +176,7 @@ def _install_loggers(cp, handlers):
# configure the root first # configure the root first
llist = cp.get("loggers", "keys") llist = cp.get("loggers", "keys")
llist = string.split(llist, ",") llist = string.split(llist, ",")
llist = map(lambda x: string.strip(x), llist)
llist.remove("root") llist.remove("root")
sectname = "logger_root" sectname = "logger_root"
root = logging.root root = logging.root
@ -190,7 +191,7 @@ def _install_loggers(cp, handlers):
if len(hlist): if len(hlist):
hlist = string.split(hlist, ",") hlist = string.split(hlist, ",")
for hand in hlist: for hand in hlist:
log.addHandler(handlers[hand]) log.addHandler(handlers[string.strip(hand)])
#and now the others... #and now the others...
#we don't want to lose the existing loggers, #we don't want to lose the existing loggers,
@ -225,7 +226,7 @@ def _install_loggers(cp, handlers):
if len(hlist): if len(hlist):
hlist = string.split(hlist, ",") hlist = string.split(hlist, ",")
for hand in hlist: for hand in hlist:
logger.addHandler(handlers[hand]) logger.addHandler(handlers[string.strip(hand)])
#Disable any old loggers. There's no point deleting #Disable any old loggers. There's no point deleting
#them as other threads may continue to hold references #them as other threads may continue to hold references