prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Workaround Crowdin bug where integer yaml keys are not preserved
  When downloading in-context localisation files, integer keys in YAML files are not preserved. This is only an issue in the file `topics/content/en/programming-challenges-structure-difficulties.yaml`, which uses the difficulty number as the key.
  
  As a work around, we can use the string value of the integer as the key, i.e. `"0"` instead of `0`
  Workaround Crowdin bug where integer yaml keys are not preserved
  When downloading in-context localisation files, integer keys in YAML files are not preserved. This is only an issue in the file `topics/content/en/programming-challenges-structure-difficulties.yaml`, which uses the difficulty number as the key.
  
  As a work around, we can use the string value of the integer as the key, i.e. `"0"` instead of `0`
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py`
  Content:
  ```
  1 """Custom loader for loading structure of programming challenges."""
  2 
  3 import os
  4 from django.db import transaction
  5 from utils.errors.MissingRequiredFieldError import MissingRequiredFieldError
  6 from utils.TranslatableModelLoader import TranslatableModelLoader
  7 from topics.models import ProgrammingChallengeLanguage, ProgrammingChallengeDifficulty
  8 
  9 
  10 class ProgrammingChallengesStructureLoader(TranslatableModelLoader):
  11     """Custom loader for loading structure of programming challenges."""
  12 
  13     @transaction.atomic
  14     def load(self):
  15         """Load the content for structure of programming challenges.
  16 
  17         Raises:
  18             MissingRequiredFieldError: when no object can be found with the matching
  19                 attribute.
  20         """
  21         structure = self.load_yaml_file(self.structure_file_path)
  22 
  23         prog_languages = structure.get("languages", None)
  24         difficulty_levels = structure.get("difficulties", None)
  25         if None in [prog_languages, difficulty_levels]:
  26             raise MissingRequiredFieldError(
  27                 self.structure_file_path,
  28                 ["lanugages", "difficulties"],
  29                 "Programming Challenge Structure"
  30             )
  31 
  32         # Add "-languages" to the structure filename
  33         prog_languages_translation_filename = "{}-languages.yaml".format(
  34             os.path.splitext(self.structure_filename)[0]
  35         )
  36         prog_languages_translations = self.get_yaml_translations(
  37             prog_languages_translation_filename,
  38             required_slugs=prog_languages.keys(),
  39             required_fields=["name"]
  40         )
  41 
  42         for (prog_language, prog_language_data) in prog_languages.items():
  43 
  44             if prog_language_data is None:
  45                 raise MissingRequiredFieldError(
  46                     self.structure_file_path,
  47                     ["number"],
  48                     "Programming Challenge Language"
  49                 )
  50 
  51             # Check for required fields
  52             prog_language_number = prog_language_data.get("number", None)
  53             if prog_language_number is None:
  54                 raise MissingRequiredFieldError(
  55                     self.structure_file_path,
  56                     ["number"],
  57                     "Programming Challenge Language"
  58                 )
  59 
  60             # Check if icon is given
  61             if "icon" in prog_language_data:
  62                 prog_language_icon = prog_language_data["icon"]
  63             else:
  64                 prog_language_icon = None
  65 
  66             new_prog_language = ProgrammingChallengeLanguage(
  67                 slug=prog_language,
  68                 number=prog_language_number,
  69                 icon=prog_language_icon
  70             )
  71 
  72             translations = prog_languages_translations.get(prog_language, dict())
  73             self.populate_translations(new_prog_language, translations)
  74             self.mark_translation_availability(new_prog_language, required_fields=["name"])
  75             new_prog_language.save()
  76 
  77             self.log("Added programming language: {}".format(new_prog_language.__str__()))
  78 
  79         # Add "-languages" to the structure filename
  80         difficulties_translation_filename = "{}-difficulties.yaml".format(
  81             os.path.splitext(self.structure_filename)[0]
  82         )
  83         difficulties_translations = self.get_yaml_translations(
  84             difficulties_translation_filename,
  85             required_slugs=difficulty_levels,
  86             required_fields=["name"],
  87         )
  88 
  89         for difficulty in difficulty_levels:
  90 
  91             new_difficulty = ProgrammingChallengeDifficulty(
  92                 level=int(difficulty),
  93             )
  94 
  95             translations = difficulties_translations.get(difficulty, dict())
  96             self.populate_translations(new_difficulty, translations)
  97             self.mark_translation_availability(new_difficulty, required_fields=["name"])
  98             new_difficulty.save()
  99 
  100             self.log("Added programming difficulty level: {}".format(new_difficulty.__str__()))
  101 
  102         self.log("")
  103
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py b/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py
  --- a/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py
  +++ b/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py
  @@ -86,13 +86,13 @@
               required_fields=["name"],
           )
   
  -        for difficulty in difficulty_levels:
  +        for level, difficulty_slug in enumerate(difficulty_levels):
   
               new_difficulty = ProgrammingChallengeDifficulty(
  -                level=int(difficulty),
  +                level=level,
               )
   
  -            translations = difficulties_translations.get(difficulty, dict())
  +            translations = difficulties_translations.get(difficulty_slug, dict())
               self.populate_translations(new_difficulty, translations)
               self.mark_translation_availability(new_difficulty, required_fields=["name"])
               new_difficulty.save()
  
verification_info: {"golden_diff": "diff --git a/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py b/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py\n--- a/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py\n+++ b/csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py\n@@ -86,13 +86,13 @@\n             required_fields=[\"name\"],\n         )\n \n-        for difficulty in difficulty_levels:\n+        for level, difficulty_slug in enumerate(difficulty_levels):\n \n             new_difficulty = ProgrammingChallengeDifficulty(\n-                level=int(difficulty),\n+                level=level,\n             )\n \n-            translations = difficulties_translations.get(difficulty, dict())\n+            translations = difficulties_translations.get(difficulty_slug, dict())\n             self.populate_translations(new_difficulty, translations)\n             self.mark_translation_availability(new_difficulty, required_fields=[\"name\"])\n             new_difficulty.save()\n", "issue": "Workaround Crowdin bug where integer yaml keys are not preserved\nWhen downloading in-context localisation files, integer keys in YAML files are not preserved. This is only an issue in the file `topics/content/en/programming-challenges-structure-difficulties.yaml`, which uses the difficulty number as the key.\r\n\r\nAs a work around, we can use the string value of the integer as the key, i.e. `\"0\"` instead of `0`\nWorkaround Crowdin bug where integer yaml keys are not preserved\nWhen downloading in-context localisation files, integer keys in YAML files are not preserved. This is only an issue in the file `topics/content/en/programming-challenges-structure-difficulties.yaml`, which uses the difficulty number as the key.\r\n\r\nAs a work around, we can use the string value of the integer as the key, i.e. `\"0\"` instead of `0`\n", "before_files": [{"content": "\"\"\"Custom loader for loading structure of programming challenges.\"\"\"\n\nimport os\nfrom django.db import transaction\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\nfrom utils.TranslatableModelLoader import TranslatableModelLoader\nfrom topics.models import ProgrammingChallengeLanguage, ProgrammingChallengeDifficulty\n\n\nclass ProgrammingChallengesStructureLoader(TranslatableModelLoader):\n    \"\"\"Custom loader for loading structure of programming challenges.\"\"\"\n\n    @transaction.atomic\n    def load(self):\n        \"\"\"Load the content for structure of programming challenges.\n\n        Raises:\n            MissingRequiredFieldError: when no object can be found with the matching\n                attribute.\n        \"\"\"\n        structure = self.load_yaml_file(self.structure_file_path)\n\n        prog_languages = structure.get(\"languages\", None)\n        difficulty_levels = structure.get(\"difficulties\", None)\n        if None in [prog_languages, difficulty_levels]:\n            raise MissingRequiredFieldError(\n                self.structure_file_path,\n                [\"lanugages\", \"difficulties\"],\n                \"Programming Challenge Structure\"\n            )\n\n        # Add \"-languages\" to the structure filename\n        prog_languages_translation_filename = \"{}-languages.yaml\".format(\n            os.path.splitext(self.structure_filename)[0]\n        )\n        prog_languages_translations = self.get_yaml_translations(\n            prog_languages_translation_filename,\n            required_slugs=prog_languages.keys(),\n            required_fields=[\"name\"]\n        )\n\n        for (prog_language, prog_language_data) in prog_languages.items():\n\n            if prog_language_data is None:\n                raise MissingRequiredFieldError(\n                    self.structure_file_path,\n                    [\"number\"],\n                    \"Programming Challenge Language\"\n                )\n\n            # Check for required fields\n            prog_language_number = prog_language_data.get(\"number\", None)\n            if prog_language_number is None:\n                raise MissingRequiredFieldError(\n                    self.structure_file_path,\n                    [\"number\"],\n                    \"Programming Challenge Language\"\n                )\n\n            # Check if icon is given\n            if \"icon\" in prog_language_data:\n                prog_language_icon = prog_language_data[\"icon\"]\n            else:\n                prog_language_icon = None\n\n            new_prog_language = ProgrammingChallengeLanguage(\n                slug=prog_language,\n                number=prog_language_number,\n                icon=prog_language_icon\n            )\n\n            translations = prog_languages_translations.get(prog_language, dict())\n            self.populate_translations(new_prog_language, translations)\n            self.mark_translation_availability(new_prog_language, required_fields=[\"name\"])\n            new_prog_language.save()\n\n            self.log(\"Added programming language: {}\".format(new_prog_language.__str__()))\n\n        # Add \"-languages\" to the structure filename\n        difficulties_translation_filename = \"{}-difficulties.yaml\".format(\n            os.path.splitext(self.structure_filename)[0]\n        )\n        difficulties_translations = self.get_yaml_translations(\n            difficulties_translation_filename,\n            required_slugs=difficulty_levels,\n            required_fields=[\"name\"],\n        )\n\n        for difficulty in difficulty_levels:\n\n            new_difficulty = ProgrammingChallengeDifficulty(\n                level=int(difficulty),\n            )\n\n            translations = difficulties_translations.get(difficulty, dict())\n            self.populate_translations(new_difficulty, translations)\n            self.mark_translation_availability(new_difficulty, required_fields=[\"name\"])\n            new_difficulty.save()\n\n            self.log(\"Added programming difficulty level: {}\".format(new_difficulty.__str__()))\n\n        self.log(\"\")\n", "path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py"}], "after_files": [{"content": "\"\"\"Custom loader for loading structure of programming challenges.\"\"\"\n\nimport os\nfrom django.db import transaction\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\nfrom utils.TranslatableModelLoader import TranslatableModelLoader\nfrom topics.models import ProgrammingChallengeLanguage, ProgrammingChallengeDifficulty\n\n\nclass ProgrammingChallengesStructureLoader(TranslatableModelLoader):\n    \"\"\"Custom loader for loading structure of programming challenges.\"\"\"\n\n    @transaction.atomic\n    def load(self):\n        \"\"\"Load the content for structure of programming challenges.\n\n        Raises:\n            MissingRequiredFieldError: when no object can be found with the matching\n                attribute.\n        \"\"\"\n        structure = self.load_yaml_file(self.structure_file_path)\n\n        prog_languages = structure.get(\"languages\", None)\n        difficulty_levels = structure.get(\"difficulties\", None)\n        if None in [prog_languages, difficulty_levels]:\n            raise MissingRequiredFieldError(\n                self.structure_file_path,\n                [\"lanugages\", \"difficulties\"],\n                \"Programming Challenge Structure\"\n            )\n\n        # Add \"-languages\" to the structure filename\n        prog_languages_translation_filename = \"{}-languages.yaml\".format(\n            os.path.splitext(self.structure_filename)[0]\n        )\n        prog_languages_translations = self.get_yaml_translations(\n            prog_languages_translation_filename,\n            required_slugs=prog_languages.keys(),\n            required_fields=[\"name\"]\n        )\n\n        for (prog_language, prog_language_data) in prog_languages.items():\n\n            if prog_language_data is None:\n                raise MissingRequiredFieldError(\n                    self.structure_file_path,\n                    [\"number\"],\n                    \"Programming Challenge Language\"\n                )\n\n            # Check for required fields\n            prog_language_number = prog_language_data.get(\"number\", None)\n            if prog_language_number is None:\n                raise MissingRequiredFieldError(\n                    self.structure_file_path,\n                    [\"number\"],\n                    \"Programming Challenge Language\"\n                )\n\n            # Check if icon is given\n            if \"icon\" in prog_language_data:\n                prog_language_icon = prog_language_data[\"icon\"]\n            else:\n                prog_language_icon = None\n\n            new_prog_language = ProgrammingChallengeLanguage(\n                slug=prog_language,\n                number=prog_language_number,\n                icon=prog_language_icon\n            )\n\n            translations = prog_languages_translations.get(prog_language, dict())\n            self.populate_translations(new_prog_language, translations)\n            self.mark_translation_availability(new_prog_language, required_fields=[\"name\"])\n            new_prog_language.save()\n\n            self.log(\"Added programming language: {}\".format(new_prog_language.__str__()))\n\n        # Add \"-languages\" to the structure filename\n        difficulties_translation_filename = \"{}-difficulties.yaml\".format(\n            os.path.splitext(self.structure_filename)[0]\n        )\n        difficulties_translations = self.get_yaml_translations(\n            difficulties_translation_filename,\n            required_slugs=difficulty_levels,\n            required_fields=[\"name\"],\n        )\n\n        for level, difficulty_slug in enumerate(difficulty_levels):\n\n            new_difficulty = ProgrammingChallengeDifficulty(\n                level=level,\n            )\n\n            translations = difficulties_translations.get(difficulty_slug, dict())\n            self.populate_translations(new_difficulty, translations)\n            self.mark_translation_availability(new_difficulty, required_fields=[\"name\"])\n            new_difficulty.save()\n\n            self.log(\"Added programming difficulty level: {}\".format(new_difficulty.__str__()))\n\n        self.log(\"\")\n", "path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py"}]}