@@ -68,62 +68,27 @@ def validation_success(self, **kwargs):
68
68
69
69
@attr .s
70
70
class _PrettyFormatter (object ):
71
- _MESSAGE_BAR_CHAR = '═'
72
- _MESSAGE_CORNER_CHARS = ( '╒' , '╕' )
73
- _MESSAGE_FORMAT = ' {}══[{}]═══({})'
71
+ _MESSAGE_BAR_CHAR = "═"
72
+ _MESSAGE_CORNER_CHARS = "╒" , "╕"
73
+ _MESSAGE_FORMAT = " {}══[{}]═══({})"
74
74
_MESSAGE_MAX_LENGTH = 79
75
75
76
76
@classmethod
77
77
def _json_formatter (cls , x ):
78
- return json .dumps (x , separators = ( ', \n ' , ': ' ) , sort_keys = True )
78
+ return json .dumps (x , indent = 4 , sort_keys = True )
79
79
80
- def _message_end_chars (self , header = False ):
81
- return self ._MESSAGE_CORNER_CHARS if header is True \
80
+ def _message_line (self , path , type , header = False ):
81
+ begin_char , end_char = self ._MESSAGE_CORNER_CHARS if header \
82
82
else [self ._MESSAGE_BAR_CHAR ] * 2
83
-
84
- def _message_line_good_unicode (self , path , type , header = False ):
85
- """
86
- Message formatter for Python interpreters with good Unicode support.
87
-
88
- TODO: Rename method when support for old Python no longer needed.
89
- """
90
- begin_char , end_char = self ._message_end_chars (header )
91
83
return self ._MESSAGE_FORMAT .format (begin_char , type , path ) \
92
84
.ljust (self ._MESSAGE_MAX_LENGTH - 1 , self ._MESSAGE_BAR_CHAR ) + \
93
85
end_char
94
86
95
- def _message_line_poor_unicode (self , path , type , header = False ):
96
- """
97
- Message formatter for Python interpreters with poor Unicode support.
98
-
99
- TODO: Remove method when support for old Python no longer needed.
100
- """
101
- begin_char , end_char = self ._message_end_chars (header )
102
-
103
- bar_length = self ._MESSAGE_MAX_LENGTH - self ._FORMAT_LENGTH - \
104
- len (type ) - len (path )
105
-
106
- return self ._MESSAGE_FORMAT .format (begin_char , type , path ) + \
107
- self ._MESSAGE_BAR_CHAR * bar_length + end_char
108
-
109
- if len (_MESSAGE_BAR_CHAR ) != 1 :
110
- # The code in this if-block is for Python interpreters that don't
111
- # treat multibyte Unicode characters as single characters.
112
- # E.g., most versions of Python 2.x.
113
- # TODO: Remove if-block when support for old Python no longer needed.
114
-
115
- _message_line = _message_line_poor_unicode
116
- _FORMAT_LENGTH = len (
117
- _MESSAGE_FORMAT .replace (_MESSAGE_BAR_CHAR , '.' )
118
- .format ('.' , '' , '' )) + 1
119
- else :
120
- _message_line = _message_line_good_unicode
121
-
122
87
def _error_msg (self , path , type , body ):
123
88
HEADER = self ._message_line (path , type , header = True )
124
- FOOTER = '└' + '─' * (self ._MESSAGE_MAX_LENGTH - 2 ) + '┘'
89
+ FOOTER = "└" + "─" * (self ._MESSAGE_MAX_LENGTH - 2 ) + "┘"
125
90
126
- return ' \n ' .join ((HEADER , str ( body ) , FOOTER , ' \n ' ))
91
+ return " \n " .join ((HEADER , body , FOOTER , " \n " ))
127
92
128
93
def filenotfound_error (self , path , exc_info ):
129
94
return self ._error_msg (
@@ -151,7 +116,7 @@ def validation_error(self, instance_path, error):
151
116
)
152
117
153
118
def validation_success (self , instance_path ):
154
- return self ._message_line (path = instance_path , type = ' SUCCESS' ) + ' \n \n '
119
+ return self ._message_line (path = instance_path , type = " SUCCESS" ) + " \n \n "
155
120
156
121
157
122
@attr .s
0 commit comments