run yamllint when parsing failed and also on fdroid lint runs

This commit is contained in:
Michael Pöhn 2020-04-24 15:47:31 +02:00
parent bb43dcf00e
commit 4e69ff582f
4 changed files with 49 additions and 16 deletions

View file

@ -42,6 +42,8 @@ import urllib.request
import zipfile
import tempfile
import json
import yamllint.config
import yamllint.linter
# TODO change to only import defusedxml once its installed everywhere
try:
@ -3734,3 +3736,18 @@ def force_exit(exitvalue=0):
sys.stdout.flush()
sys.stderr.flush()
os._exit(exitvalue)
YAML_LINT_CONFIG = {'extends': 'default',
'rules': {'document-start': 'disable',
'line-length': 'disable',
'truthy': 'disable'}}
def run_yamllint(path, indent=0):
result = []
with open(path, 'r', encoding='utf-8') as f:
problems = yamllint.linter.run(f, yamllint.config.YamlLintConfig(json.dumps(YAML_LINT_CONFIG)))
for problem in problems:
result.append(' ' * indent + path + ':' + str(problem.line) + ': ' + problem.message)
return '\n'.join(result)