mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 07:22:29 +03:00
make yamllint optional
This commit is contained in:
parent
4e69ff582f
commit
975538a7a7
1 changed files with 7 additions and 2 deletions
|
@ -42,8 +42,6 @@ import urllib.request
|
||||||
import zipfile
|
import zipfile
|
||||||
import tempfile
|
import tempfile
|
||||||
import json
|
import json
|
||||||
import yamllint.config
|
|
||||||
import yamllint.linter
|
|
||||||
|
|
||||||
# TODO change to only import defusedxml once its installed everywhere
|
# TODO change to only import defusedxml once its installed everywhere
|
||||||
try:
|
try:
|
||||||
|
@ -3745,6 +3743,13 @@ YAML_LINT_CONFIG = {'extends': 'default',
|
||||||
|
|
||||||
|
|
||||||
def run_yamllint(path, indent=0):
|
def run_yamllint(path, indent=0):
|
||||||
|
|
||||||
|
try:
|
||||||
|
import yamllint.config
|
||||||
|
import yamllint.linter
|
||||||
|
except ImportError:
|
||||||
|
return ''
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
with open(path, 'r', encoding='utf-8') as f:
|
with open(path, 'r', encoding='utf-8') as f:
|
||||||
problems = yamllint.linter.run(f, yamllint.config.YamlLintConfig(json.dumps(YAML_LINT_CONFIG)))
|
problems = yamllint.linter.run(f, yamllint.config.YamlLintConfig(json.dumps(YAML_LINT_CONFIG)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue