merge folderbased config file into global settings

This commit is contained in:
Robert Kaussow 2019-04-09 10:36:52 +02:00
parent 60e4694e7f
commit c2397b498a
2 changed files with 11 additions and 16 deletions

View File

@ -116,7 +116,7 @@ class Candidate(object):
labels["id"] = standard.id labels["id"] = standard.id
for err in [err for err in result.errors 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 = copy.copy(labels)
err_labels["passed"] = False err_labels["passed"] = False
if isinstance(err, Error): if isinstance(err, Error):
@ -141,15 +141,6 @@ class Candidate(object):
path=self.path, path=self.path,
error=err), extra=flag_extra(err_labels)) error=err), extra=flag_extra(err_labels))
errors = errors + 1 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): def _format_id(self, standard_id):
if standard_id and standard_id.strip(): if standard_id and standard_id.strip():

View File

@ -70,14 +70,18 @@ class Settings(object):
def _get_config(self): def _get_config(self):
defaults = self._get_defaults() 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 cli_options = self.args
if config_file and os.path.exists(config_file): for config in source_files:
with utils.open_file(config_file) as stream: if config and os.path.exists(config):
s = stream.read() with utils.open_file(config) as stream:
if self._validate(utils.safe_load(s)): s = stream.read()
anyconfig.merge(defaults, utils.safe_load(s), ac_merge=anyconfig.MS_DICTS) 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): if cli_options and self._validate(cli_options):
anyconfig.merge(defaults, cli_options, ac_merge=anyconfig.MS_DICTS) anyconfig.merge(defaults, cli_options, ac_merge=anyconfig.MS_DICTS)