Expand some of the exceptions
This commit is contained in:
parent
e9e12da793
commit
20a2646646
1 changed files with 4 additions and 4 deletions
|
|
@ -904,7 +904,7 @@ def funcparser_callable_pad(*args, **kwargs):
|
||||||
nrest = len(rest)
|
nrest = len(rest)
|
||||||
try:
|
try:
|
||||||
width = int(kwargs.get("width", rest[0] if nrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
width = int(kwargs.get("width", rest[0] if nrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
width = _CLIENT_DEFAULT_WIDTH
|
width = _CLIENT_DEFAULT_WIDTH
|
||||||
|
|
||||||
align = kwargs.get("align", rest[1] if nrest > 1 else "c")
|
align = kwargs.get("align", rest[1] if nrest > 1 else "c")
|
||||||
|
|
@ -936,7 +936,7 @@ def funcparser_callable_crop(*args, **kwargs):
|
||||||
nrest = len(rest)
|
nrest = len(rest)
|
||||||
try:
|
try:
|
||||||
width = int(kwargs.get("width", rest[0] if nrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
width = int(kwargs.get("width", rest[0] if nrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
width = _CLIENT_DEFAULT_WIDTH
|
width = _CLIENT_DEFAULT_WIDTH
|
||||||
suffix = kwargs.get("suffix", rest[1] if nrest > 1 else "[...]")
|
suffix = kwargs.get("suffix", rest[1] if nrest > 1 else "[...]")
|
||||||
return crop(str(text), width=width, suffix=str(suffix))
|
return crop(str(text), width=width, suffix=str(suffix))
|
||||||
|
|
@ -982,12 +982,12 @@ def funcparser_callable_justify(*args, **kwargs):
|
||||||
lrest = len(rest)
|
lrest = len(rest)
|
||||||
try:
|
try:
|
||||||
width = int(kwargs.get("width", rest[0] if lrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
width = int(kwargs.get("width", rest[0] if lrest > 0 else _CLIENT_DEFAULT_WIDTH))
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
width = _CLIENT_DEFAULT_WIDTH
|
width = _CLIENT_DEFAULT_WIDTH
|
||||||
align = str(kwargs.get("align", rest[1] if lrest > 1 else "f"))
|
align = str(kwargs.get("align", rest[1] if lrest > 1 else "f"))
|
||||||
try:
|
try:
|
||||||
indent = int(kwargs.get("indent", rest[2] if lrest > 2 else 0))
|
indent = int(kwargs.get("indent", rest[2] if lrest > 2 else 0))
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
indent = 0
|
indent = 0
|
||||||
return justify(str(text), width=width, align=align, indent=indent)
|
return justify(str(text), width=width, align=align, indent=indent)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue