update_38.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # Contest Management System - http://cms-dev.github.io/
  3. # Copyright © 2018 Luca Wehrstedt <luca.wehrstedt@gmail.com>
  4. # Copyright © 2019 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. """A class to update a dump created by CMS.
  19. Used by DumpImporter and DumpUpdater.
  20. Add default values to the task type parameters of Communication for the
  21. newly-introduced fields 'compilation' and 'user_io'.
  22. """
  23. class Updater:
  24. def __init__(self, data):
  25. assert data["_version"] == 37
  26. self.objs = data
  27. def run(self):
  28. for k, v in self.objs.items():
  29. if k.startswith("_"):
  30. continue
  31. if v["_class"] == "Dataset" and v["task_type"] == "Communication":
  32. params = v["task_type_parameters"]
  33. if len(params) == 1:
  34. params.extend(["stub", "fifo_io"])
  35. v["task_type_parameters"] = params
  36. return self.objs