11from cStringIO import StringIO
22
33from configobj import ConfigObj , flatten_errors
4- from validate import Validator
4+ from validate import Validator , is_string_list
55
66import logging
77
2424synchronization interval = integer(min=1, default=1440)
2525
2626transcode = option("no", "unsupported", "all", default="no")
27- transcode unsupported = list (default=list("flac"))
27+ transcode unsupported = lowercase_string_list (default=list("flac"))
2828
2929[Daap]
3030interface = string(default="0.0.0.0")
5252""" % CONFIG_VERSION
5353
5454
55+ def lowercase_string_list (value , min = None , max = None ):
56+ """
57+ Custom ConfigObj validator that returns a list of lowercase
58+ items.
59+ """
60+ validated_string_list = is_string_list (value , min , max )
61+ return [x .lower () for x in validated_string_list ]
62+
63+
5564def get_config (config_file ):
5665 """
5766 Parse the config file, validate it and convert types. Return a dictionary
@@ -62,7 +71,7 @@ def get_config(config_file):
6271 config = ConfigObj (config_file , configspec = specs )
6372
6473 # Create validator
65- validator = Validator ()
74+ validator = Validator ({ 'lowercase_string_list' : lowercase_string_list } )
6675
6776 # Convert types and validate file
6877 result = config .validate (validator , preserve_errors = True , copy = True )
@@ -79,10 +88,6 @@ def get_config(config_file):
7988 "The following section was missing: %s." % (
8089 ", " .join (section_list )))
8190
82- # Post-process values
83- config ["Provider" ]["item transcode unsupported" ] = [
84- x .lower () for x in config ["Provider" ]["item transcode unsupported" ]]
85-
8691 # For now, no automatic update support.
8792 if config ["version" ] != CONFIG_VERSION :
8893 logger .warning (
0 commit comments