Add global "locale" config option and make key-ordering rule locale-aware

Support sorting by locale with strcoll(). Properly handle case and accents.
This commit is contained in:
Wolfgang Walther
2020-07-15 11:46:05 +02:00
committed by GitHub
parent a2218988ee
commit 9e90c777cb
6 changed files with 138 additions and 16 deletions

View File

@@ -35,6 +35,8 @@ class YamlLintConfig(object):
self.yaml_files = pathspec.PathSpec.from_lines(
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
self.locale = 'C.UTF-8'
if file is not None:
with open(file) as f:
content = f.read()
@@ -111,6 +113,12 @@ class YamlLintConfig(object):
self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch',
conf['yaml-files'])
if 'locale' in conf:
if not isinstance(conf['locale'], str):
raise YamlLintConfigError(
'invalid config: locale should be a string')
self.locale = conf['locale']
def validate(self):
for id in self.rules:
try: