summarystats.py 1.5 KB

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