mirror of https://github.com/Textualize/rich.git
added isascii function for pythn3.6
This commit is contained in:
parent
05bf78b17a
commit
5a075eb118
|
@ -85,8 +85,8 @@ class ReprHighlighter(RegexHighlighter):
|
|||
_combine_regex(
|
||||
r"(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})",
|
||||
r"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})",
|
||||
r"(?P<eui64>([0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})",
|
||||
r"(?P<eui48>([0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})",
|
||||
r"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})",
|
||||
r"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})",
|
||||
r"(?P<brace>[\{\[\(\)\]\}])",
|
||||
r"(?P<attrib_name>\w+?)=(?P<attrib_value>\"?[\w_]+\"?)?",
|
||||
r"(?P<bool_true>True)|(?P<bool_false>False)|(?P<none>None)",
|
||||
|
|
|
@ -42,9 +42,13 @@ class Rule(JupyterMixin):
|
|||
) -> RenderResult:
|
||||
width = options.max_width
|
||||
|
||||
# Python3.6 doesn't have an isascii method on str
|
||||
isascii = getattr(str, "isascii", None) or (
|
||||
lambda s: all(ord(c) < 128 for c in s)
|
||||
)
|
||||
characters = (
|
||||
"-"
|
||||
if (options.ascii_only and not self.characters.isascii())
|
||||
if (options.ascii_only and not isascii(self.characters))
|
||||
else self.characters
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue