Format code with black. Add makefile to run fmt/tests

This commit is contained in:
Griatch 2019-09-28 18:18:11 +02:00
parent d00bce9288
commit c2c7fa311a
299 changed files with 19037 additions and 11611 deletions

View file

@ -41,8 +41,7 @@ _SCREEN_HEIGHT = settings.CLIENT_DEFAULT_HEIGHT
# text
_DISPLAY = \
"""{text}
_DISPLAY = """{text}
(|wmore|n [{pageno}/{pagemax}] retur|wn|n|||wb|nack|||wt|nop|||we|nnd|||wq|nuit)"""
@ -50,9 +49,9 @@ class CmdMore(Command):
"""
Manipulate the text paging
"""
key = _CMD_NOINPUT
aliases = ["quit", "q", "abort", "a", "next", "n",
"back", "b", "top", "t", "end", "e"]
aliases = ["quit", "q", "abort", "a", "next", "n", "back", "b", "top", "t", "end", "e"]
auto_help = False
def func(self):
@ -85,6 +84,7 @@ class CmdMoreLook(Command):
"""
Override look to display window and prevent OOCLook from firing
"""
key = "look"
aliases = ["l"]
auto_help = False
@ -106,6 +106,7 @@ class CmdSetMore(CmdSet):
"""
Stores the more command
"""
key = "more_commands"
priority = 110
@ -119,9 +120,17 @@ class EvMore(object):
The main pager object
"""
def __init__(self, caller, text, always_page=False, session=None,
justify_kwargs=None, exit_on_lastpage=False,
exit_cmd=None, **kwargs):
def __init__(
self,
caller,
text,
always_page=False,
session=None,
justify_kwargs=None,
exit_on_lastpage=False,
exit_cmd=None,
**kwargs,
):
"""
Initialization of the text handler.
@ -183,7 +192,7 @@ class EvMore(object):
justify_kwargs = justify_kwargs or {}
width = justify_kwargs.get("width", width)
justify_kwargs["width"] = width
justify_kwargs["align"] = justify_kwargs.get("align", 'l')
justify_kwargs["align"] = justify_kwargs.get("align", "l")
justify_kwargs["indent"] = justify_kwargs.get("indent", 0)
lines = []
@ -196,7 +205,7 @@ class EvMore(object):
# always limit number of chars to 10 000 per page
height = min(10000 // max(1, width), height)
self._pages = ["\n".join(lines[i:i + height]) for i in range(0, len(lines), height)]
self._pages = ["\n".join(lines[i : i + height]) for i in range(0, len(lines), height)]
self._npages = len(self._pages)
self._npos = 0
@ -219,9 +228,7 @@ class EvMore(object):
pos = self._pos
text = self._pages[pos]
if show_footer:
page = _DISPLAY.format(text=text,
pageno=pos + 1,
pagemax=self._npages)
page = _DISPLAY.format(text=text, pageno=pos + 1, pagemax=self._npages)
else:
page = text
# check to make sure our session is still valid
@ -283,8 +290,15 @@ class EvMore(object):
self._caller.execute_cmd(self.exit_cmd, session=self._session)
def msg(caller, text="", always_page=False, session=None,
justify_kwargs=None, exit_on_lastpage=True, **kwargs):
def msg(
caller,
text="",
always_page=False,
session=None,
justify_kwargs=None,
exit_on_lastpage=True,
**kwargs,
):
"""
More-supported version of msg, mimicking the normal msg method.
@ -304,5 +318,12 @@ def msg(caller, text="", always_page=False, session=None,
to the `caller.msg` method.
"""
EvMore(caller, text, always_page=always_page, session=session,
justify_kwargs=justify_kwargs, exit_on_lastpage=exit_on_lastpage, **kwargs)
EvMore(
caller,
text,
always_page=always_page,
session=session,
justify_kwargs=justify_kwargs,
exit_on_lastpage=exit_on_lastpage,
**kwargs,
)