Jason Tackaberry wrote: > On Fri, 2009-06-12 at 10:36 +0200, A Mennucc wrote: >> --- video/videoitem.py.orig 2009-05-16 20:10:55.000000000 +0200 >> +++ video/videoitem.py 2009-05-29 11:34:38.000000000 +0200 >> @@ -375,6 +375,9 @@ >> length = s.length >> if not length: >> continue >> + if type(length) != int: >> + _debug_(' length is %s ???' % repr(length), 3) >> + continue >> total += length > > Fails unnecessarily if length is a float. This is more pythonic: > > try: > total += length > except TypeError: > _debug_('Invalid length: %r' % length, 3)
This is a the way to do it but sometimes %r can fail, I find it always works when the value is turned into a tuple like '%r' % (length,). What is also sensible is to give some information about which sub-item Freevo cannot handle. Useful is to use the __dict__ member of the 's' variable to find a useful member to include in the debug message. Something like '%s' % s.__dict__ will help and when the object is very big then '%s' % (pprint.pformat(s.__dict__),) will help. Duncan ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel