export_gamelist_xml_file.py 825 B

12345678910111213141516171819202122232425262728
  1. import xml.etree.ElementTree as ET
  2. from django.core.management.base import BaseCommand, CommandError
  3. from games.utils import export_gamelist_file_to_path_for_system
  4. class Command(BaseCommand):
  5. help = "Export all games found to a given gamelist XML file"
  6. def add_arguments(self, parser):
  7. parser.add_argument("system", type=str)
  8. parser.add_argument(
  9. "--file",
  10. action="store_true",
  11. help="Export to a specific file",
  12. )
  13. def handle(self, *args, **options):
  14. games, file_path = export_gamelist_file_to_path_for_system(
  15. options["system"],
  16. options["file"],
  17. )
  18. self.stdout.write(
  19. self.style.SUCCESS(
  20. f"Successfully exported {len(games)} games to {file_path}"
  21. )
  22. )