Add global "locale" config option and make key-ordering rule locale-aware
Support sorting by locale with strcoll(). Properly handle case and accents. Note: this is a second implementation, for context see: https://github.com/adrienverge/yamllint/pull/280 https://github.com/adrienverge/yamllint/issues/285 https://github.com/adrienverge/yamllint/pull/288
This commit is contained in:
@@ -35,6 +35,8 @@ class YamlLintConfig(object):
|
||||
self.yaml_files = pathspec.PathSpec.from_lines(
|
||||
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
|
||||
|
||||
self.locale = None
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user