export_gamelist_xml_file.py 741 B

123456789101112131415161718192021222324
  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 = export_gamelist_file_to_path_for_system(
  15. options["system"],
  16. options["file"],
  17. )
  18. self.stdout.write(self.style.SUCCESS(f"Successfully exported {len(games)}"))