androlyze.settings package¶
Subpackages¶
Submodules¶
androlyze.settings.Settings module¶
-
class
androlyze.settings.Settings.
Settings
(config_path, default_path=None, *args, **kwargs)[source]¶ Bases:
object
This class is a wrapper around a ConfigParser to retrieve and write settings in a more convenient way.
For (over)writing settings, be sure to use the with construct! Otherwise the file handle will not be closed.
Examples
>>> # just for doctest passing tests (file needs to exist) >>> f = open("test.conf", "w") >>> f.close()
>>> # the entries >>> entry = ("SectionName", "Option1") >>> entry2 = ("SectionName", "Option2") >>> entry3 = ("SectionName2", "Option1")
>>> # If you want to write some settings use the with construct to close the file after writing! >>> s = None >>> try: ... with Settings("test.conf") as s: ... s[entry] = "value1" ... s[entry2] = "value2" ... s[entry3] = "value1" ... except ConfigFileNotFoundError as e: ... pass ... finally: ... print s Settings: SectionName : [('option1', 'value1'), ('option2', 'value2')], SectionName2 : [('option1', 'value1')]
>>> # read settings >>> try: ... print s[entry] ... print len(s) ... print entry in s ... for section, items in s: ... print '%s : %s' % (section, items) ... except ConfigFileNotFoundError: ... pass value1 3 True SectionName : [('option1', 'value1'), ('option2', 'value2')] SectionName2 : [('option1', 'value1')]
Attributes
Methods
-
config_parser
¶ ConfigParser : the parser for the config file
-
get_apk_storage_engine
()[source]¶ Get the apk storage engine. See keys settings.APK_STORAGE_ENGINE_*
-
get_bool
(key, **kwargs)[source]¶ Get an boolean value from a section and option.
Parameters: key : tuple<str, str>
First argument is the section and the second the option
Other Parameters: default : str, optional (default is ‘default_val’)
If not found, return the default value. If value is the default, an exception will be raised. You can also use None as a default value.
Raises: ConfigError
If default not customized.
-
get_celery_broker_ssl_opts
()[source]¶ Create dictionary which can be directly passed to BROKER_USE_SSL celery config
-
get_int
(key, **kwargs)[source]¶ Get an int value from a section and option.
Parameters: key : tuple<str, str>
First argument is the section and the second the option
Other Parameters: default : str, optional (default is ‘default_val’)
If not found, return the default value. If value is the default, an exception will be raised. You can also use None as a default value.
Raises: ConfigError
If default not customized.
-
get_list
(key, **kwargs)[source]¶ Get an list value from a section and option. Values have to be comma separated (without ” or ‘).
Parameters: key : tuple<str, str>
First argument is the section and the second the option
Other Parameters: default : str, optional (default is ‘default_val’)
If not found, return the default value. If value is the default, an exception will be raised. You can also use None as a default value.
Raises: ConfigError
If default not customized.
-