def handle(self, *args, **options): """Automatically called when the loadgeneralpages command is given.""" base_path = settings.GENERAL_PAGES_CONTENT_BASE_PATH general_pages_structure_file = "general-pages.yaml" factory = LoaderFactory() factory.create_general_pages_loader( structure_filename=general_pages_structure_file, base_path=base_path).load()
def handle(self, *args, **options): """Automatically called when the loadresources command is given.""" BASE_PATH = "resources/content/{}" resource_structure_file = "resources.yaml" factory = LoaderFactory() factory.create_resources_loader(resource_structure_file, BASE_PATH).load()
def handle(self, *args, **options): """Automatically called when the load_questions command is given.""" base_path = settings.QUESTIONS_BASE_PATH questions_structure_file = 'questions.yaml' factory = LoaderFactory() factory.create_questions_loader( structure_filename=questions_structure_file, base_path=base_path).load()
def handle(self, *args, **options): """Automatically called when the loadclassicpages command is given.""" base_path = settings.CLASSIC_PAGES_CONTENT_BASE_PATH classic_pages_structure_file = "classic-pages.yaml" factory = LoaderFactory() factory.create_classic_pages_loader( structure_filename=classic_pages_structure_file, base_path=base_path).load()
def handle(self, *args, **options): """Automatically called when the loadresources command is given.""" base_path = settings.RESOURCES_CONTENT_BASE_PATH resource_structure_file = "resources.yaml" factory = LoaderFactory() factory.create_resources_loader( structure_filename=resource_structure_file, base_path=base_path).load()
def handle(self, *args, **options): """Automatically called when the loadappendices command is given.""" base_path = settings.APPENDICES_CONTENT_BASE_PATH appendices_structure_file = "appendices.yaml" factory = LoaderFactory() loader = factory.create_appendices_loader( structure_filename=appendices_structure_file, base_path=base_path) loader.log("All appendices loaded!") loader.log("")
def handle(self, *args, **options): """Automatically called when the loadinteractives command is given.""" factory = LoaderFactory() base_path = settings.INTERACTIVES_CONTENT_BASE_PATH loader = factory.create_interactives_loader( base_path=base_path, content_path="", structure_filename="interactives.yaml") loader.load() loader.log("All interactives loaded!") loader.log("")
def handle(self, *args, **options): """Automatically called when the loadcurriculumguides command is given.""" factory = LoaderFactory() # Get structure and content files base_loader = BaseLoader() base_path = settings.CURRICULUM_GUIDES_CONTENT_BASE_PATH structure_file_path = os.path.join(base_path, base_loader.structure_dir, "structure.yaml") structure_file = base_loader.load_yaml_file(structure_file_path) curriculum_guides = structure_file.get("curriculum_guides", None) if curriculum_guides is None: raise MissingRequiredFieldError(structure_file_path, ["curriculum_guides"], "Application Structure") else: for curriculum_guide_slug in curriculum_guides: curriculum_guide_structure_file = "{}.yaml".format( curriculum_guide_slug) curriculum_guide_number = curriculum_guides[ curriculum_guide_slug].get("curriculum-guide-number", None) if curriculum_guide_number is None: raise MissingRequiredFieldError( structure_file_path, ["curriculum_guide_number"], "Application Structure for Curriculum Guide {}".format( curriculum_guide_slug)) if isinstance(curriculum_guide_number, int) is False: raise InvalidYAMLValueError( structure_file_path, "curriculum-guide-number - value '{}' is invalid". format(curriculum_guide_number), "curriculum-guide-number must be an integer value.") factory.create_curriculum_guide_loader( base_path=base_path, content_path=curriculum_guide_slug, curriculum_guide_number=curriculum_guide_number, structure_filename=curriculum_guide_structure_file, ).load() base_loader.log("All curriculum guides loaded!") base_loader.log("")
def handle(self, *args, **options): """Automatically called when the loadactivities command is given. Raise: MissingRequiredFieldError: when no object can be found with the matching attribute. """ lite_load = options.get("lite_load") factory = LoaderFactory() # Get structure and content files base_loader = BaseLoader() base_path = settings.ACTIVITIES_CONTENT_BASE_PATH structure_file_path = os.path.join(base_path, base_loader.structure_dir, "activities.yaml") structure_file = base_loader.load_yaml_file(structure_file_path) if structure_file.get("activities", None) is None or not isinstance( structure_file["activities"], dict): raise MissingRequiredFieldError(structure_file_path, ["activities"], "At Home") else: for activity_slug, activity_data in structure_file[ "activities"].items(): activity_path = activity_slug activity_structure_file = "{}.yaml".format(activity_slug) factory.create_activity_loader( base_path=base_path, content_path=activity_path, structure_filename=activity_structure_file, lite_loader=lite_load, activity_data=activity_data, ).load()
def handle(self, *args, **options): """Automatically called when the loadchapters command is given.""" factory = LoaderFactory() # Get structure and content files base_loader = BaseLoader() base_path = settings.CHAPTERS_CONTENT_BASE_PATH structure_file_path = os.path.join(base_path, base_loader.structure_dir, "structure.yaml") structure_file = base_loader.load_yaml_file(structure_file_path) if "glossary-folder" in structure_file: glossary_directory = structure_file["glossary-folder"] if glossary_directory is not None: factory.create_glossary_terms_loader( base_path=base_path, content_path=glossary_directory, ).load() chapters = structure_file.get("chapters", None) if chapters is None: raise MissingRequiredFieldError(structure_file_path, ["chapters"], "Application Structure") else: for chapter_slug in chapters: chapter_structure_file = "{}.yaml".format(chapter_slug) chapter_number = chapters[chapter_slug].get( "chapter-number", None) if chapter_number is None: raise MissingRequiredFieldError( structure_file_path, ["chapter_number"], "Application Structure for Chapter {}".format( chapter_slug)) if isinstance(chapter_number, int) is False: raise InvalidYAMLValueError( structure_file_path, "chapter-number - value '{}' is invalid".format( chapter_number), "chapter-number must be an integer value.") factory.create_chapter_loader( base_path=base_path, content_path=chapter_slug, chapter_number=chapter_number, structure_filename=chapter_structure_file, ).load() base_loader.log("All chapters loaded!") base_loader.log("")
def handle(self, *args, **options): """Automatically called when the loadresources command is given. Raise: MissingRequiredFieldError: when no object can be found with the matching attribute. """ factory = LoaderFactory() lite_load = options.get("lite_load") # Get structure and content files base_loader = BaseLoader() base_path = settings.TOPICS_CONTENT_BASE_PATH structure_file_path = os.path.join(base_path, base_loader.structure_dir, "structure.yaml") structure_file = base_loader.load_yaml_file(structure_file_path) if "curriculum-areas" in structure_file: curriculum_areas_structure_file_path = structure_file[ "curriculum-areas"] if curriculum_areas_structure_file_path is not None: curriculum_areas_path, structure_filename = os.path.split( curriculum_areas_structure_file_path) factory.create_curriculum_areas_loader( base_path=base_path, content_path=curriculum_areas_path, structure_filename=structure_filename).load() if "learning-outcomes" in structure_file: learning_outcomes_structure_file_path = structure_file[ "learning-outcomes"] if learning_outcomes_structure_file_path is not None: learning_outcomes_path, structure_filename = os.path.split( learning_outcomes_structure_file_path) factory.create_learning_outcomes_loader( base_path=base_path, content_path=learning_outcomes_path, structure_filename=structure_filename).load() if "programming-challenges-structure" in structure_file: programming_challenges_structure_file_path = structure_file[ "programming-challenges-structure"] if programming_challenges_structure_file_path is not None: programming_challenges_path, structure_filename = os.path.split( programming_challenges_structure_file_path) factory.create_programming_challenges_structure_loader( base_path=base_path, content_path=programming_challenges_path, structure_filename=structure_filename).load() if "classroom-resources" in structure_file: classroom_resources_structure_file_path = structure_file[ "classroom-resources"] if classroom_resources_structure_file_path is not None: classroom_resources_path, structure_filename = os.path.split( classroom_resources_structure_file_path) factory.create_classroom_resources_loader( base_path=base_path, content_path=classroom_resources_path, structure_filename=structure_filename).load() if "glossary-folder" in structure_file: glossary_folder_path = structure_file["glossary-folder"] if glossary_folder_path is not None: factory.create_glossary_terms_loader( base_path=base_path, content_path=glossary_folder_path, ).load() age_groups_structure_file_path = structure_file.get("age-groups", None) if age_groups_structure_file_path is None: raise MissingRequiredFieldError(structure_file_path, ["age-groups"], "Application Structure") else: age_groups_path, structure_filename = os.path.split( age_groups_structure_file_path) factory.create_age_groups_loader( content_path=age_groups_path, base_path=base_path, structure_filename=structure_filename).load() if structure_file.get("topics", None) is None or not isinstance( structure_file["topics"], list): raise MissingRequiredFieldError(structure_file_path, ["topics"], "Application Structure") else: for topic in structure_file["topics"]: topic_path = topic topic_structure_file = "{}.yaml".format(topic) factory.create_topic_loader( base_path=base_path, content_path=topic_path, structure_filename=topic_structure_file, lite_loader=lite_load, ).load()
def handle(self, *args, **options): """Automatically called when the loadresources command is given. Raise: MissingRequiredFieldError: when no object can be found with the matching attribute. """ factory = LoaderFactory() # Get structure and content files base_loader = BaseLoader() BASE_PATH = "topics/content/en/" structure_file_path = os.path.join(BASE_PATH, "structure.yaml") structure_file = base_loader.load_yaml_file(structure_file_path) if "curriculum-areas" in structure_file: curriculum_areas_structure_file_path = structure_file[ "curriculum-areas"] if curriculum_areas_structure_file_path is not None: factory.create_curriculum_areas_loader( curriculum_areas_structure_file_path, BASE_PATH).load() if "learning-outcomes" in structure_file: learning_outcomes_structure_file_path = structure_file[ "learning-outcomes"] if learning_outcomes_structure_file_path is not None: factory.create_learning_outcomes_loader( learning_outcomes_structure_file_path, BASE_PATH).load() if "programming-challenges-structure" in structure_file: programming_challenges_structure_file_path = structure_file[ "programming-challenges-structure"] if programming_challenges_structure_file_path is not None: factory.create_programming_challenges_structure_loader( programming_challenges_structure_file_path, BASE_PATH).load() if "glossary-folder" in structure_file: glossary_folder_path = structure_file["glossary-folder"] if glossary_folder_path is not None: factory.create_glossary_terms_loader(glossary_folder_path, structure_file_path, BASE_PATH).load() if structure_file["age-groups"] is None: raise MissingRequiredFieldError(structure_file_path, ["age-groups"], "Application Structure") else: age_groups_path = structure_file["age-groups"] if age_groups_path is not None: factory.create_age_groups_loader(age_groups_path, BASE_PATH).load() if structure_file["topics"] is None: raise MissingRequiredFieldError(structure_file_path, ["topics"], "Application Structure") for topic in structure_file["topics"]: topic_structure_file = "{0}/{0}.yaml".format(topic) factory.create_topic_loader(topic_structure_file, BASE_PATH).load()