parse_msgfmt.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. # Contest Management System - http://cms-dev.github.io/
  3. # Copyright © 2014 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
  4. # Copyright © 2016 Stefano Maggiolo <s.maggiolo@gmail.com>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. import os
  19. import sys
  20. def main():
  21. for line in sys.stdin:
  22. filename, data = [x.strip() for x in line.split(':')]
  23. filename = os.path.basename(filename.strip('.'))
  24. pieces = [x.strip() for x in data.split(',')]
  25. stats = {'translated': 0, 'untranslated': 0, 'fuzzy': 0}
  26. for piece in pieces:
  27. words = piece.split(' ')
  28. stats[words[1]] = int(words[0])
  29. print("%s,%d,%d,%d" % (filename,
  30. stats['translated'],
  31. stats['untranslated'],
  32. stats['fuzzy']))
  33. if __name__ == '__main__':
  34. main()