mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-26 03:40:26 +00:00
Comment Match.__str__ and use format() to simplify calculation
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
This commit is contained in:
parent
d73cec1e09
commit
fb86ac70f5
@ -77,15 +77,16 @@ class Match(): # pylint: disable=too-few-public-methods
|
|||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ln_str = str(self.pos[0])
|
"""
|
||||||
gutter_len = max(4, len(ln_str))
|
Return a formatted code listing representation of the erroneous line.
|
||||||
gutter = (gutter_len - len(ln_str)) * " " + ln_str
|
"""
|
||||||
|
gutter = format(self.pos[0], "4d")
|
||||||
underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^"
|
underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
" {0} |\n".format(gutter_len * " ") +
|
" {0} |\n".format(" " * len(gutter)) +
|
||||||
" {0} | {1}".format(gutter, self.line) +
|
" {0} | {1}".format(gutter, self.line) +
|
||||||
" {0} | {1}\n".format(gutter_len * " ", underline)
|
" {0} | {1}\n".format(" " * len(gutter), underline)
|
||||||
)
|
)
|
||||||
|
|
||||||
class Problem(): # pylint: disable=too-few-public-methods
|
class Problem(): # pylint: disable=too-few-public-methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user