فهرست منبع

Actually export to the right place

Colin Powell 3 سال پیش
والد
کامیت
4c65c3e631

+ 6 - 2
games/management/commands/export_gamelist_xml_file.py

@@ -17,8 +17,12 @@ class Command(BaseCommand):
         )
 
     def handle(self, *args, **options):
-        games = export_gamelist_file_to_path_for_system(
+        games, file_path = export_gamelist_file_to_path_for_system(
             options["system"],
             options["file"],
         )
-        self.stdout.write(self.style.SUCCESS(f"Successfully exported {len(games)}"))
+        self.stdout.write(
+            self.style.SUCCESS(
+                f"Successfully exported {len(games)} games to {file_path}"
+            )
+        )

+ 3 - 1
games/management/commands/import_gamelist_xml_file.py

@@ -20,7 +20,9 @@ class Command(BaseCommand):
             options["file"],
         )
         if games:
-            self.stdout.write(self.style.SUCCESS(f"Successfully imported {len(games)}"))
+            self.stdout.write(
+                self.style.SUCCESS(f"Successfully imported {len(games)} games")
+            )
         else:
             self.stdout.write(
                 self.style.ERROR(

+ 2 - 2
games/utils.py

@@ -128,7 +128,7 @@ def export_gamelist_file_to_path_for_system(game_system_slug, file_path=None):
     root = ET.Element("gameList")
 
     tree = ET.ElementTree(root)
-    tree.write("filename.xml")
+    tree.write(file_path)
     games = Game.objects.filter(game_system=game_system)
     for game in games:
         game_node = ET.SubElement(root, "game")
@@ -163,4 +163,4 @@ def export_gamelist_file_to_path_for_system(game_system_slug, file_path=None):
     tree = ET.ElementTree(root)
     tree.write(file_path, xml_declaration=True, encoding="utf-8")
 
-    return exported_games
+    return exported_games, file_path