mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-22 04:40:42 +00:00
merge folderbased config file into global settings
This commit is contained in:
parent
60e4694e7f
commit
c2397b498a
@ -116,7 +116,7 @@ class Candidate(object):
|
||||
labels["id"] = standard.id
|
||||
|
||||
for err in [err for err in result.errors
|
||||
if not err.lineno or utils.is_line_in_ranges(err.lineno, utils.lines_ranges(lines))]:
|
||||
if not err.lineno or utils.is_line_in_ranges(err.lineno, utils.lines_ranges(lines))]: # noqa
|
||||
err_labels = copy.copy(labels)
|
||||
err_labels["passed"] = False
|
||||
if isinstance(err, Error):
|
||||
@ -141,15 +141,6 @@ class Candidate(object):
|
||||
path=self.path,
|
||||
error=err), extra=flag_extra(err_labels))
|
||||
errors = errors + 1
|
||||
# if not result.errors:
|
||||
# if not standard.version:
|
||||
# LOG.info("Best practice '%s' met" % standard.name, extra=flag_extra(labels))
|
||||
# elif LooseVersion(standard.version) > LooseVersion(self.version):
|
||||
# LOG.info("Future standard '%s' met" % standard.name, extra=flag_extra(labels))
|
||||
# else:
|
||||
# LOG.info("Standard '%s' met" % standard.name)
|
||||
|
||||
return errors
|
||||
|
||||
def _format_id(self, standard_id):
|
||||
if standard_id and standard_id.strip():
|
||||
|
@ -70,14 +70,18 @@ class Settings(object):
|
||||
|
||||
def _get_config(self):
|
||||
defaults = self._get_defaults()
|
||||
config_file = self.config_file
|
||||
source_files = []
|
||||
source_files.append(self.config_file)
|
||||
source_files.append(os.path.relpath(os.path.normpath(os.path.join(os.getcwd(), ".later"))))
|
||||
cli_options = self.args
|
||||
|
||||
if config_file and os.path.exists(config_file):
|
||||
with utils.open_file(config_file) as stream:
|
||||
s = stream.read()
|
||||
if self._validate(utils.safe_load(s)):
|
||||
anyconfig.merge(defaults, utils.safe_load(s), ac_merge=anyconfig.MS_DICTS)
|
||||
for config in source_files:
|
||||
if config and os.path.exists(config):
|
||||
with utils.open_file(config) as stream:
|
||||
s = stream.read()
|
||||
sdict = utils.safe_load(s)
|
||||
if self._validate(sdict):
|
||||
anyconfig.merge(defaults, sdict, ac_merge=anyconfig.MS_DICTS)
|
||||
|
||||
if cli_options and self._validate(cli_options):
|
||||
anyconfig.merge(defaults, cli_options, ac_merge=anyconfig.MS_DICTS)
|
||||
|
Loading…
Reference in New Issue
Block a user