diff options
author | say <say@yandex-team.com> | 2023-02-14 17:24:43 +0300 |
---|---|---|
committer | say <say@yandex-team.com> | 2023-02-14 17:24:43 +0300 |
commit | e0094c4ad6964e11564777bc0d859c68d8aa9de2 (patch) | |
tree | 5d2ad1a4df88da1f74385888891a2a5f9fbbc3ef /library/python/testing/custom_linter_util/reporter.py | |
parent | 65a08c9fdece8dba50da8beb4d7c81447211dd45 (diff) | |
download | ydb-e0094c4ad6964e11564777bc0d859c68d8aa9de2.tar.gz |
Migrate black linter on custom_lint pipeline
Diffstat (limited to 'library/python/testing/custom_linter_util/reporter.py')
-rw-r--r-- | library/python/testing/custom_linter_util/reporter.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/library/python/testing/custom_linter_util/reporter.py b/library/python/testing/custom_linter_util/reporter.py new file mode 100644 index 0000000000..8ae559bca0 --- /dev/null +++ b/library/python/testing/custom_linter_util/reporter.py @@ -0,0 +1,39 @@ +import json +import sys +from enum import Enum +from typing import Optional + + +class LintStatus(Enum): + GOOD = "GOOD" + FAIL = "FAIL" + SKIPPED = "SKIPPED" + + +class LintReport(): + def __init__(self): + self._report = {} + + def add(self, file_name: str, status: LintStatus, message: str = "", elapsed: float = 0.0): + self._report[file_name] = { + "status": status.value, + "message": message, + "elapsed": elapsed, + } + + def dump(self, report_file, pretty: Optional[bool] = None): + data = { + "report": self._report, + } + if report_file == "-": + if pretty is None: + pretty = True + self._do_dump(sys.stdout, data, pretty) + else: + with open(report_file, "w") as f: + self._do_dump(f, data, pretty) + + @staticmethod + def _do_dump(dest, data, pretty): + indent = 4 if pretty else None + json.dump(data, dest, indent=indent) |