Add optional default
param to Exports.get_one()
(src/Exports.py)
This commit is contained in:
parent
a3ca29dabe
commit
76fd67235a
1 changed files with 5 additions and 3 deletions
|
@ -29,7 +29,8 @@ class Exports(object):
|
||||||
return self._exports.get(setting, []) + sum([
|
return self._exports.get(setting, []) + sum([
|
||||||
exports.get(setting, []) for exports in
|
exports.get(setting, []) for exports in
|
||||||
self._context_exports.values()], [])
|
self._context_exports.values()], [])
|
||||||
def get_one(self, setting: str) -> typing.Optional[typing.Any]:
|
def get_one(self, setting: str, default: typing.Any=None
|
||||||
|
) -> typing.Optional[typing.Any]:
|
||||||
values = self.get_all(setting)
|
values = self.get_all(setting)
|
||||||
return values[0] if values else None
|
return values[0] if values else None
|
||||||
|
|
||||||
|
@ -46,5 +47,6 @@ class ExportsContext(object):
|
||||||
self._parent._context_add(self.context, setting, value)
|
self._parent._context_add(self.context, setting, value)
|
||||||
def get_all(self, setting: str) -> typing.List[typing.Any]:
|
def get_all(self, setting: str) -> typing.List[typing.Any]:
|
||||||
return self._parent.get_all(setting)
|
return self._parent.get_all(setting)
|
||||||
def get_one(self, setting: str) -> typing.Optional[typing.Any]:
|
def get_one(self, setting: str, default: typing.Any=None
|
||||||
return self._parent.get_one(setting)
|
) -> typing.Optional[typing.Any]:
|
||||||
|
return self._parent.get_one(setting, default)
|
||||||
|
|
Loading…
Reference in a new issue