Make WuttaConfig.get_list()
return None
by default
instead of empty list `[]`
This commit is contained in:
parent
16e9811816
commit
24a86ffeb4
|
@ -5,6 +5,11 @@ All notable changes to WuttJamaican will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
### Changed
|
||||||
|
- `WuttaConfig.get_list()` now returns `None` (instead of `[]`) by
|
||||||
|
default if there is no config value present.
|
||||||
|
|
||||||
## [0.1.9] - 2023-11-30
|
## [0.1.9] - 2023-11-30
|
||||||
### Changed
|
### Changed
|
||||||
- Add generic handler base class, tests, docs.
|
- Add generic handler base class, tests, docs.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -480,9 +480,13 @@ class WuttaConfig:
|
||||||
Accepts same params as :meth:`get()` but if a value is found,
|
Accepts same params as :meth:`get()` but if a value is found,
|
||||||
it will be coerced to list via
|
it will be coerced to list via
|
||||||
:func:`~wuttjamaican.util.parse_list()`.
|
:func:`~wuttjamaican.util.parse_list()`.
|
||||||
|
|
||||||
|
:returns: If a value is found, a list is returned. If no
|
||||||
|
value, returns ``None``.
|
||||||
"""
|
"""
|
||||||
value = self.get(*args, **kwargs)
|
value = self.get(*args, **kwargs)
|
||||||
return parse_list(value)
|
if value is not None:
|
||||||
|
return parse_list(value)
|
||||||
|
|
||||||
def get_dict(self, prefix):
|
def get_dict(self, prefix):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -370,7 +370,7 @@ configure_logging = true
|
||||||
|
|
||||||
def test_get_list(self):
|
def test_get_list(self):
|
||||||
config = conf.WuttaConfig()
|
config = conf.WuttaConfig()
|
||||||
self.assertEqual(config.get_list('foo.bar'), [])
|
self.assertIsNone(config.get_list('foo.bar'))
|
||||||
config.setdefault('foo.bar', 'hello world')
|
config.setdefault('foo.bar', 'hello world')
|
||||||
self.assertEqual(config.get_list('foo.bar'), ['hello', 'world'])
|
self.assertEqual(config.get_list('foo.bar'), ['hello', 'world'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue