summarystats.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # vim:set et sw=4:
  3. """
  4. Simple summary class for dak
  5. @contact: Debian FTP Master <ftpmaster@debian.org>
  6. @copyright: 2001 - 2006 James Troup <james@nocrew.org>
  7. @copyright: 2009 Joerg Jaspert <joerg@debian.org>
  8. @license: GNU General Public License version 2 or later
  9. """
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. ###############################################################################
  22. class SummaryStats(object):
  23. __shared_state = {}
  24. def __init__(self, *args, **kwargs):
  25. self.__dict__ = self.__shared_state
  26. if not getattr(self, 'initialised', False):
  27. self.initialised = True
  28. self.reset_accept()
  29. self.reset_reject()
  30. def reset_accept(self):
  31. self.accept_count = 0
  32. self.accept_bytes = 0
  33. def reset_reject(self):
  34. self.reject_count = 0