@@ -70,18 +70,21 @@ def validation_success(self, **kwargs):
70
70
@attr .s
71
71
class _PrettyFormatter (object ):
72
72
73
- _ERROR_MSG = dedent (
74
- """\
75
- ===[{type}]===({path})===
73
+ _WIDTH = 79
76
74
77
- {body}
78
- -----------------------------
79
- """ ,
80
- )
81
- _SUCCESS_MSG = "===[SUCCESS]===({path})===\n "
75
+ def _simple_msg (self , path , type , header = False ):
76
+ begin_end_chars = '╒╕' if header is True else '══'
77
+ return '{}══[{}]═══({})' .format (begin_end_chars [0 ], type , path )\
78
+ .ljust (self ._WIDTH - 1 , '═' ) + begin_end_chars [1 ]
79
+
80
+ def _error_msg (self , path , type , body ):
81
+ HEADER = self ._simple_msg (path , type , header = True )
82
+ FOOTER = '└' + '─' * (self ._WIDTH - 2 ) + '┘'
83
+
84
+ return '\n ' .join ((HEADER , str (body ), FOOTER , '\n ' ))
82
85
83
86
def filenotfound_error (self , path , exc_info ):
84
- return self ._ERROR_MSG . format (
87
+ return self ._error_msg (
85
88
path = path ,
86
89
type = "FileNotFoundError" ,
87
90
body = "{!r} does not exist." .format (path ),
@@ -92,21 +95,21 @@ def parsing_error(self, path, exc_info):
92
95
exc_lines = "" .join (
93
96
traceback .format_exception (exc_type , exc_value , exc_traceback ),
94
97
)
95
- return self ._ERROR_MSG . format (
98
+ return self ._error_msg (
96
99
path = path ,
97
100
type = exc_type .__name__ ,
98
101
body = exc_lines ,
99
102
)
100
103
101
104
def validation_error (self , instance_path , error ):
102
- return self ._ERROR_MSG . format (
105
+ return self ._error_msg (
103
106
path = instance_path ,
104
107
type = error .__class__ .__name__ ,
105
108
body = error ,
106
109
)
107
110
108
111
def validation_success (self , instance_path ):
109
- return self ._SUCCESS_MSG . format (path = instance_path )
112
+ return self ._simple_msg (path = instance_path , type = 'SUCCESS' ) + ' \n \n '
110
113
111
114
112
115
@attr .s
0 commit comments