2323import collections
2424from abc import ABCMeta , abstractproperty , abstractmethod
2525from operator import methodcaller , itemgetter
26+
2627from .python .doc import Doc
2728from .python .decorlib import propertydoc
2829
@@ -180,6 +181,7 @@ def ife_ancestry_snapshot_text(self) -> [(object, str, str)]:
180181 x , getattr (x , 'ife_label' , type (x ).__name__ ),
181182 (x .ife_snapshot_text () if hasattr (x , 'ife_snapshot_text' ) else str (x ))
182183 ) for x in a
184+ if getattr (x , '_ife_exclude_snapshot' , False ) is not True
183185 ]
184186 return l
185187
@@ -224,10 +226,10 @@ def ife_emit(self,
224226 property get, etc).
225227
226228 To handle these additional results, the object is passed up through the
227- ancestry. Any ancestor that has receptors will see the object
229+ ancestry. Any ancestor that has receptors will see the object.
228230
229231 If `obj` was consumed by a receptor, the receptor that consumed it will be
230- returned
232+ returned.
231233 """
232234 # Don't include ancestors without receptors.
233235 a = [
@@ -244,6 +246,7 @@ def ife_emit(self,
244246 if r is True and allow_consumption :
245247 # receptor indicated halt
246248 return (recep , ife )
249+ # if went unstopped
247250 return False
248251
249252 def ife_connect (self ,
@@ -263,8 +266,9 @@ def ife_connect(self,
263266 self ._ife_receptors = list (args )
264267 return
265268 # Prepend the list. Newer receptors are given priority.
266- new = list (recept )
267- self ._ife_receptors = new .extend (self ._ife_receptors )
269+ new = list (args )
270+ new .extend (self ._ife_receptors )
271+ self ._ife_receptors = new
268272
269273 def ife_sever (self ,
270274 * args : (Receptor ,)
@@ -337,31 +341,57 @@ def __repr__(self):
337341 )
338342 )
339343
340- def ife_snapshot_text (self ):
344+ def __str__ (self ):
345+ ss = getattr (self , 'snapshot' , None )
346+ if ss is None :
347+ ss = obj .ife_ancestry_snapshot_text ()
348+ sev = self .details .get ('severity' , self .ife_label ).upper ()
349+ detailstr = self .details_string
350+ if detailstr :
351+ detailstr = os .linesep + detailstr
352+ locstr = self .location_string
353+ if locstr :
354+ locstr = os .linesep + locstr
355+
356+ code = "" if not self .code or self .code == "00000" else '(' + self .code + ')'
357+ return sev + code + ': ' + self .message + locstr + detailstr + \
358+ os .linesep + \
359+ os .linesep .join ([': ' .join (x [1 :]) for x in ss ]) + \
360+ os .linesep
361+
362+ @property
363+ def location_string (self ):
341364 details = self .details
342365 loc = [
343366 details .get (k , '?' ) for k in ('file' , 'line' , 'function' )
344367 ]
345- locstr = (
346- "" if tuple (loc ) == ('?' , '?' , '?' )
347- else os .linesep + \
348- "LOCATION: File {0!r}, " \
349- "line {1!s}, in {2!s}" .format (* loc )
368+ return (
369+ "" if loc == ['?' , '?' , '?' ]
370+ else "LOCATION: File {0!r}, " \
371+ "line {1!s}, in {2!s}" .format (* loc )
350372 )
351373
352- code = (os .linesep + "CODE: " + self .code ) if self .code else ""
374+ @property
375+ def details_string (self ):
376+ return os .linesep .join ((
377+ ': ' .join ((k .upper (), str (v )))
378+ for k , v in sorted (self .details .items (), key = itemgetter (0 ))
379+ if k not in ('message' , 'severity' , 'file' , 'function' , 'line' )
380+ ))
353381
382+ def ife_snapshot_text (self ):
383+ details = self .details
384+ code = (os .linesep + "CODE: " + self .code ) if self .code else ""
354385 sev = details .get ('severity' )
355386 sevmsg = ""
356387 if sev :
357388 sevmsg = os .linesep + "SEVERITY: " + sev .upper ()
358- detailstr = os .linesep .join ((
359- ': ' .join ((k .upper (), str (v )))
360- for k , v in sorted (details .items (), key = itemgetter (0 ))
361- if k not in ('message' , 'severity' , 'file' , 'function' , 'line' )
362- ))
389+ detailstr = self .details_string
363390 if detailstr :
364391 detailstr = os .linesep + detailstr
392+ locstr = self .location_string
393+ if locstr :
394+ locstr = os .linesep + locstr
365395 return self .message + code + sevmsg + detailstr + locstr
366396
367397 def emit (self ):
0 commit comments