import_gamelist_xml_file.py 701 B

12345678910111213141516171819202122
  1. from django.core.management.base import BaseCommand, CommandError
  2. from games.utils import import_gamelist_file_to_db_for_system
  3. class Command(BaseCommand):
  4. help = "Import all games found in a given gamelist XML file"
  5. def add_arguments(self, parser):
  6. parser.add_argument("system", type=str)
  7. parser.add_argument(
  8. "--file",
  9. action="store_true",
  10. help="Import from specific file",
  11. )
  12. def handle(self, *args, **options):
  13. games = import_gamelist_file_to_db_for_system(
  14. options["system"],
  15. options["file"],
  16. )
  17. self.stdout.write(self.style.SUCCESS(f"Successfully imported {len(games)}"))