1234567891011121314151617181920212223242526272829303132333435363738 |
- from django.core.management.base import BaseCommand, CommandError
- from games.utils import import_gamelist_file_to_db_for_system
- class Command(BaseCommand):
- help = "Import all games found in a given gamelist XML file"
- def add_arguments(self, parser):
- parser.add_argument("system", type=str)
- parser.add_argument(
- "--file",
- action="store_true",
- help="Import from specific file",
- )
- parser.add_argument(
- "--full-scan",
- type=bool,
- default=False,
- help="Update all files, even ones we already know about",
- )
- def handle(self, *args, **options):
- games = import_gamelist_file_to_db_for_system(
- options["system"],
- options["file"],
- options["full_scan"],
- )
- if games:
- self.stdout.write(
- self.style.SUCCESS(f"Successfully imported {len(games)} games")
- )
- else:
- self.stdout.write(
- self.style.ERROR(
- "No games imported, check for gamelist.xml file or re-run scraper"
- )
- )
|