Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Is there a more elegant way to handle determing fail status? (http://www.velocityreviews.com/forums/t956549-re-is-there-a-more-elegant-way-to-handle-determing-fail-status.html)

Ian Kelly 01-16-2013 12:01 AM

Re: Is there a more elegant way to handle determing fail status?
 
On Tue, Jan 15, 2013 at 4:24 PM, J <dreadpiratejeff@gmail.com> wrote:
> The exit code determination above works, but it just feels inelegant.
> It feels like there's a better way of implementing that, but I can't
> come up with one that still honors the fail level properly (e.g. other
> solutions will fail on medium, but won't fail properly on medium OR
> higher).


First, instead of having separate variables 'critical_fails',
'high_fails', etc., put them in a collections.Counter 'fails' keyed by
fail level.
Second, make sure those fail level keys are orderable by severity.

Then your check is just:

if fail_priority <= max(fails):
return 1
return 0


All times are GMT. The time now is 04:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.