add the possilibity to use the content of a section as a list. Ie, instead of doing "source.exclude_dirs = dir1,dir2", just create a section [app:source.exclude_dirs], and put one directory per line.

This commit is contained in:
Mathieu Virbel 2013-08-24 01:21:27 +02:00
parent 103aa72f8c
commit 5c540b0413
2 changed files with 25 additions and 0 deletions

View file

@ -832,6 +832,13 @@ class Buildozer(object):
def _get_config_list(self, section, token, default=None):
# monkey-patch method for ConfigParser
# get a key as a list of string, seperated from the comma
# if a section:token is defined, let's use the content as a list.
l_section = '{}:{}'.format(section, token)
if self.config.has_section(l_section):
values = self.config.options(l_section)
return [x.strip() for x in values]
values = self.config.getdefault(section, token, '')
if not values:
return default

View file

@ -112,3 +112,21 @@ fullscreen = 1
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 1
# -----------------------------------------------------------------------------
# Alternatively, you can define all the "list" as [section:key].
# Each line will be considered as a option to the list.
# Let's take [app] / source.exclude_patterns.
# Instead of doing:
#
# [app]
# source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
# This can be translated into:
#
# [app:source.exclude_patterns]
# license
# data/audio/*.wav
# data/images/original/*
#