Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tearDown(self):
confuse.yaml_util.load_yaml, os.path.isfile = self._old
def setUp(self):
self._old = os.path.isfile, confuse.yaml_util.load_yaml
os.path.isfile = lambda x: True
confuse.yaml_util.load_yaml = lambda *args, **kwargs: {}
def setUp(self):
self._old = os.path.isfile, confuse.yaml_util.load_yaml
os.path.isfile = lambda x: True
confuse.yaml_util.load_yaml = lambda *args, **kwargs: {}
def _add_user_source(self):
"""Add the configuration options from the YAML file in the
user's configuration directory (given by `config_dir`) if it
exists.
"""
filename = self.user_config_path()
if os.path.isfile(filename):
yaml_data = yaml_util.load_yaml(filename, loader=self.loader) \
or {}
self.add(ConfigSource(yaml_data, filename))
def set_file(self, filename):
"""Parses the file as YAML and inserts it into the configuration
sources with highest priority.
"""
filename = os.path.abspath(filename)
yaml_data = yaml_util.load_yaml(filename, loader=self.loader)
self.set(ConfigSource(yaml_data, filename))
def _add_default_source(self):
"""Add the package's default configuration settings. This looks
for a YAML file located inside the package for the module
`modname` if it was given.
"""
if self.modname:
if self._package_path:
filename = os.path.join(self._package_path, DEFAULT_FILENAME)
if os.path.isfile(filename):
yaml_data = yaml_util.load_yaml(
filename,
loader=self.loader,
)
self.add(ConfigSource(yaml_data, filename, True))