-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoss_service.py
More file actions
21 lines (18 loc) · 836 Bytes
/
Copy pathmoss_service.py
File metadata and controls
21 lines (18 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from mosspy import Moss # type: ignore
from helpers.codemaze_logger import CodemazeLogger
from helpers.commons import secure_filename, file_extension
class MossService:
def __init__(self, user_id: str) -> None:
self.__user_id = user_id
def get_report(self, source_file_path_name_list: list[tuple[str, str]], language: str) -> str | None:
moss = Moss(self.__user_id, language)
if language not in moss.getLanguages():
return None
try:
for path, name in source_file_path_name_list:
moss.addFile(path, secure_filename(name) + file_extension(path))
return str(moss.send())
# pylint: disable=broad-exception-caught
except Exception:
CodemazeLogger.shared().exception('MOSS Service has failed.')
return None