@@ -108,7 +108,7 @@ def compare(previous, current, show_unchanged=False):
108108 return result
109109
110110
111- def human_text (result , key = None , singular = None , plural = None , show_unchanged = False ):
111+ def human_text (result , key = None , singular = None , plural = None , current = None , extras = None ):
112112 singular = singular or "row"
113113 plural = plural or "rows"
114114 title = []
@@ -151,6 +151,9 @@ def human_text(result, key=None, singular=None, plural=None, show_unchanged=Fals
151151 block .append (
152152 ' {}: "{}" => "{}"' .format (field , prev_value , current_value )
153153 )
154+ if extras :
155+ current_item = current [details ["key" ]]
156+ block .append (human_extras (current_item , extras ))
154157 block .append ("" )
155158 change_blocks .append ("\n " .join (block ))
156159 if details .get ("unchanged" ):
@@ -170,7 +173,10 @@ def human_text(result, key=None, singular=None, plural=None, show_unchanged=Fals
170173 summary .append (fragment + "\n " )
171174 rows = []
172175 for row in result ["added" ]:
173- rows .append (human_row (row , prefix = " " ))
176+ to_append = human_row (row , prefix = " " )
177+ if extras :
178+ to_append += "\n " + human_extras (row , extras )
179+ rows .append (to_append )
174180 summary .append ("\n \n " .join (rows ))
175181 summary .append ("" )
176182 if result ["removed" ]:
@@ -182,7 +188,10 @@ def human_text(result, key=None, singular=None, plural=None, show_unchanged=Fals
182188 summary .append (fragment + "\n " )
183189 rows = []
184190 for row in result ["removed" ]:
185- rows .append (human_row (row , prefix = " " ))
191+ to_append = human_row (row , prefix = " " )
192+ if extras :
193+ to_append += "\n " + human_extras (row , extras )
194+ rows .append (to_append )
186195 summary .append ("\n \n " .join (rows ))
187196 summary .append ("" )
188197 return (", " .join (title ) + "\n \n " + ("\n " .join (summary ))).strip ()
@@ -193,3 +202,11 @@ def human_row(row, prefix=""):
193202 for key , value in row .items ():
194203 bits .append ("{}{}: {}" .format (prefix , key , value ))
195204 return "\n " .join (bits )
205+
206+
207+ def human_extras (row , extras ):
208+ bits = []
209+ bits .append (" extras:" )
210+ for key , fmt in extras :
211+ bits .append (" {}: {}" .format (key , fmt .format (** row )))
212+ return "\n " .join (bits )
0 commit comments