Settings now allow providing a custom "config" dict to work on
Can be used to always retrieve the defaults (by providing an empty config dict) or to utilize the get method with other settings than the system settings.
This commit is contained in:
parent
2d54ab5fcf
commit
c9f5476588
1 changed files with 8 additions and 7 deletions
|
|
@ -757,13 +757,14 @@ class Settings(object):
|
|||
|
||||
#~~ getter
|
||||
|
||||
def get(self, path, asdict=False, defaults=None, preprocessors=None, merged=False):
|
||||
def get(self, path, asdict=False, config=None, defaults=None, preprocessors=None, merged=False):
|
||||
import octoprint.util as util
|
||||
|
||||
if len(path) == 0:
|
||||
return None
|
||||
|
||||
config = self._config
|
||||
if config is None:
|
||||
config = self._config
|
||||
if defaults is None:
|
||||
defaults = default_settings
|
||||
if preprocessors is None:
|
||||
|
|
@ -820,7 +821,7 @@ class Settings(object):
|
|||
else:
|
||||
return results
|
||||
|
||||
def getInt(self, path, defaults=None, preprocessors=None):
|
||||
def getInt(self, path, config=None, defaults=None, preprocessors=None):
|
||||
value = self.get(path, defaults=defaults, preprocessors=preprocessors)
|
||||
if value is None:
|
||||
return None
|
||||
|
|
@ -831,8 +832,8 @@ class Settings(object):
|
|||
self._logger.warn("Could not convert %r to a valid integer when getting option %r" % (value, path))
|
||||
return None
|
||||
|
||||
def getFloat(self, path, defaults=None, preprocessors=None):
|
||||
value = self.get(path, defaults=defaults, preprocessors=preprocessors)
|
||||
def getFloat(self, path, config=None, defaults=None, preprocessors=None):
|
||||
value = self.get(path, config=config, defaults=defaults, preprocessors=preprocessors)
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
|
|
@ -842,8 +843,8 @@ class Settings(object):
|
|||
self._logger.warn("Could not convert %r to a valid integer when getting option %r" % (value, path))
|
||||
return None
|
||||
|
||||
def getBoolean(self, path, defaults=None, preprocessors=None):
|
||||
value = self.get(path, defaults=defaults, preprocessors=preprocessors)
|
||||
def getBoolean(self, path, config=None, defaults=None, preprocessors=None):
|
||||
value = self.get(path, config=config, defaults=defaults, preprocessors=preprocessors)
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, bool):
|
||||
|
|
|
|||
Loading…
Reference in a new issue