mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Fix some mypy errors
This commit is contained in:
parent
7d48972967
commit
d5dd5aac06
@ -1,25 +1,8 @@
|
||||
import logging
|
||||
|
||||
from .ffm import *
|
||||
from .ilias import *
|
||||
from .norbert import *
|
||||
from .tgi import *
|
||||
from .tgi_jimbo import *
|
||||
from .ti import *
|
||||
from .os_exams import *
|
||||
from .utils import *
|
||||
|
||||
__all__ = ["STYLE", "FORMAT", "DATE_FORMAT", "FORMATTER", "enable_logging"]
|
||||
|
||||
__all__ += ffm.__all__
|
||||
__all__ += ilias.__all__
|
||||
__all__ += norbert.__all__
|
||||
__all__ += tgi.__all__
|
||||
__all__ += tgi_jimbo.__all__
|
||||
__all__ += ti.__all__
|
||||
__all__ += utils.__all__
|
||||
__all__ += os_exams.__all__
|
||||
|
||||
STYLE = "{"
|
||||
FORMAT = "[{levelname:<7}] {message}"
|
||||
DATE_FORMAT = "%F %T"
|
||||
@ -30,7 +13,7 @@ FORMATTER = logging.Formatter(
|
||||
style=STYLE,
|
||||
)
|
||||
|
||||
def enable_logging(name="PFERD", level=logging.INFO):
|
||||
def enable_logging(name: str = "PFERD", level: int = logging.INFO) -> None:
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(FORMATTER)
|
||||
|
||||
|
@ -1,37 +1,42 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
from colorama import Style
|
||||
from colorama import Fore
|
||||
from pathlib import Path, PurePath
|
||||
from typing import Optional, Tuple
|
||||
|
||||
def move(path, from_folders, to_folders):
|
||||
import requests
|
||||
from colorama import Fore, Style
|
||||
|
||||
|
||||
def move(path: PurePath, from_folders: Tuple[str], to_folders: Tuple[str]) -> Optional[PurePath]:
|
||||
l = len(from_folders)
|
||||
if path.parts[:l] == from_folders:
|
||||
return pathlib.PurePath(*to_folders, *path.parts[l:])
|
||||
return PurePath(*to_folders, *path.parts[l:])
|
||||
return None
|
||||
|
||||
def rename(path, to_name):
|
||||
return pathlib.PurePath(*path.parts[:-1], to_name)
|
||||
def rename(path: PurePath, to_name: str) -> PurePath:
|
||||
return PurePath(*path.parts[:-1], to_name)
|
||||
|
||||
def stream_to_path(response, to_path, chunk_size=1024**2):
|
||||
def stream_to_path(response: requests.Response, to_path: Path, chunk_size: int = 1024 ** 2) -> None:
|
||||
with open(to_path, 'wb') as fd:
|
||||
for chunk in response.iter_content(chunk_size=chunk_size):
|
||||
fd.write(chunk)
|
||||
|
||||
class PrettyLogger:
|
||||
|
||||
def __init__(self, logger):
|
||||
def __init__(self, logger: logging.Logger) -> None:
|
||||
self.logger = logger
|
||||
|
||||
def modified_file(self, file_name):
|
||||
def modified_file(self, file_name: Path) -> None:
|
||||
self.logger.info(f"{Fore.MAGENTA}{Style.BRIGHT}Modified {file_name}.{Style.RESET_ALL}")
|
||||
|
||||
def new_file(self, file_name):
|
||||
def new_file(self, file_name: Path) -> None:
|
||||
self.logger.info(f"{Fore.GREEN}{Style.BRIGHT}Created {file_name}.{Style.RESET_ALL}")
|
||||
|
||||
def ignored_file(self, file_name):
|
||||
def ignored_file(self, file_name: Path) -> None:
|
||||
self.logger.info(f"{Style.DIM}Ignored {file_name}.{Style.RESET_ALL}")
|
||||
|
||||
def starting_synchronizer(self, target_directory, synchronizer_name, subject=None):
|
||||
def starting_synchronizer(self, target_directory: Path, synchronizer_name: str, subject: Optional[str] = None) -> None:
|
||||
subject_str = f"{subject} " if subject else ""
|
||||
self.logger.info("")
|
||||
self.logger.info((
|
||||
|
Loading…
Reference in New Issue
Block a user