Commit bb36177e authored by Link Mauve's avatar Link Mauve

yapf -ir

parent e4d9baa9
......@@ -105,7 +105,8 @@ class Logger:
log.debug('Log handle for %s re-created', room)
return None
def _check_and_create_log_dir(self, room: str, open_fd: bool = True) -> Optional[IO[Any]]:
def _check_and_create_log_dir(self, room: str,
open_fd: bool = True) -> Optional[IO[Any]]:
"""
Check that the directory where we want to log the messages
exists. if not, create it
......@@ -131,7 +132,8 @@ class Logger:
'Unable to open the log file (%s)', filename, exc_info=True)
return None
def get_logs(self, jid: str, nb: int = 10) -> Optional[List[Dict[str, Any]]]:
def get_logs(self, jid: str,
nb: int = 10) -> Optional[List[Dict[str, Any]]]:
"""
Get the nb last messages from the log history for the given jid.
Note that a message may be more than one line in these files, so
......@@ -176,7 +178,12 @@ class Logger:
return None
return parse_log_lines(lines)
def log_message(self, jid: str, nick: str, msg: str, date: Optional[datetime] = None, typ: int = 1) -> bool:
def log_message(self,
jid: str,
nick: str,
msg: str,
date: Optional[datetime] = None,
typ: int = 1) -> bool:
"""
log the message in the appropriate jid's file
type:
......@@ -253,7 +260,10 @@ class Logger:
return True
def build_log_message(nick: str, msg: str, date: Optional[datetime] = None, typ: int = 1) -> str:
def build_log_message(nick: str,
msg: str,
date: Optional[datetime] = None,
typ: int = 1) -> str:
"""
Create a log message from a nick, a message, optionally a date and type
message types:
......
......@@ -200,11 +200,13 @@ class TextBuffer:
"""Mark a message as acked"""
return self._edit_ack(1, old_id, jid)
def nack_message(self, error: str, old_id: str, jid: str) -> Union[None, bool, Message]:
def nack_message(self, error: str, old_id: str,
jid: str) -> Union[None, bool, Message]:
"""Mark a message as errored"""
return self._edit_ack(-1, old_id, jid, append=error)
def _edit_ack(self, value: int, old_id: str, jid: str, append: str = '') -> Union[None, bool, Message]:
def _edit_ack(self, value: int, old_id: str, jid: str,
append: str = '') -> Union[None, bool, Message]:
"""
Edit the ack status of a message, and optionally
append some text.
......
......@@ -383,7 +383,8 @@ theme = Theme()
# Each time we use a color tuple, we check if it has already been used.
# If not we create a new color_pair and keep it in that dict, to use it
# the next time.
curses_colors_dict = {} # type: Dict[Union[Tuple[int, int], Tuple[int, int, str]], int]
curses_colors_dict = {
} # type: Dict[Union[Tuple[int, int], Tuple[int, int, str]], int]
# yapf: disable
......@@ -433,7 +434,8 @@ def read_tuple(_str: str) -> Tuple[Tuple[int, int], str]:
@functools.lru_cache(maxsize=128)
def to_curses_attr(color_tuple: Union[Tuple[int, int], Tuple[int, int, str]]) -> int:
def to_curses_attr(
color_tuple: Union[Tuple[int, int], Tuple[int, int, str]]) -> int:
"""
Takes a color tuple (as defined at the top of this file) and
returns a valid curses attr that can be passed directly to attron() or attroff()
......@@ -484,7 +486,8 @@ def get_theme() -> Theme:
return theme
def update_themes_dir(option: Optional[str] = None, value: Optional[str] = None):
def update_themes_dir(option: Optional[str] = None,
value: Optional[str] = None):
global load_path
load_path = []
......
......@@ -299,7 +299,8 @@ def get_hash(data: bytes) -> str:
class XHTMLHandler(sax.ContentHandler):
def __init__(self, force_ns=False, tmp_image_dir: Optional[Path] = None) -> None:
def __init__(self, force_ns=False,
tmp_image_dir: Optional[Path] = None) -> None:
self.builder = [] # type: List[str]
self.formatting = [] # type: List[str]
self.attrs = [] # type: List[Dict[str, str]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment