Fix py3 regression in ansi filler divisor. Resolves #1804.

This commit is contained in:
Griatch 2019-03-31 18:45:21 +02:00
parent ee5f4044e8
commit f485099b7b
3 changed files with 8 additions and 6 deletions

View file

@ -98,6 +98,7 @@ Web/Django standard initiative (@strikaco)
- Convert ServerConf model to store its values as a Picklefield (same as Attributes) instead of using a custom solution.
- OOB: Add support for MSDP LIST, REPORT, UNREPORT commands (re-mapped to `msdp_list`,
`msdp_report`, `msdp_unreport` inlinefuncs_)
- Added `evennia.ANSIString` to flat API.
### Utils

View file

@ -101,6 +101,7 @@ EvTable = None
EvForm = None
EvEditor = None
EvMore = None
ANSIString = None
# Handlers
SESSION_HANDLER = None
@ -153,6 +154,7 @@ def _init():
global settings, lockfuncs, logger, utils, gametime, ansi, spawn, managers
global contrib, TICKER_HANDLER, MONITOR_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER, TASK_HANDLER
global EvMenu, EvTable, EvForm, EvMore, EvEditor
global ANSIString
from .accounts.accounts import DefaultAccount
from .accounts.accounts import DefaultGuest
@ -203,6 +205,7 @@ def _init():
from .utils.evtable import EvTable
from .utils.evform import EvForm
from .utils.eveditor import EvEditor
from .utils.ansi import ANSIString
# handlers
from .scripts.tickerhandler import TICKER_HANDLER

View file

@ -13,6 +13,7 @@ user. Depreciated example forms are available by extending
the ansi mapping.
"""
import functools
from builtins import object, range
import re
@ -534,8 +535,8 @@ def _spacing_preflight(func):
functions used for padding ANSIStrings.
"""
def wrapped(self, width, fillchar=None):
@functools.wraps(func)
def wrapped(self, width=78, fillchar=None):
if fillchar is None:
fillchar = " "
if (len(fillchar) != 1) or (not isinstance(fillchar, str)):
@ -555,7 +556,6 @@ def _query_super(func_name):
of ANSIString.
"""
def wrapped(self, *args, **kwargs):
return getattr(self.clean(), func_name)(*args, **kwargs)
return wrapped
@ -566,7 +566,6 @@ def _on_raw(func_name):
Like query_super, but makes the operation run on the raw string.
"""
def wrapped(self, *args, **kwargs):
args = list(args)
try:
@ -593,7 +592,6 @@ def _transform(func_name):
with the resulting string.
"""
def wrapped(self, *args, **kwargs):
replacement_string = _query_super(func_name)(self, *args, **kwargs)
to_string = []
@ -1289,7 +1287,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)):
"""
remainder = _difference % 2
_difference /= 2
_difference //= 2
spacing = self._filler(fillchar, _difference)
result = spacing + self + spacing + self._filler(fillchar, remainder)
return result