def get_workout(self, guitar: dict = None) -> workout.WorkOut:
        """ Returns a new workout containing all practices """
        exercises = []
        practice_objects = Inspector.get_classes_in_container(
            Container(["practice"]), ["abstract"], [
                "AbstractPractice", "AbstractUrlList", "PracticeCategory",
                "PracticeCategoryGroup", "Position", "Guitar",
                "SupportPractice", "Accent"
            ])

        AllPractices._delete_duplicates(practice_objects)

        if "only_select" in self._config["practice_selection"]:
            only_select = self._config["practice_selection"]["only_select"]
            if only_select != "":
                for practice_object in practice_objects:
                    if practice_object.__module__ == only_select:
                        random_step_count = self._get_random_step_count()
                        produced_exercise = practice_object().get_exercise(
                            random_step_count, guitar)
                        exercises.append(produced_exercise)
                        output = workout.WorkOut(exercises)
                        return output

        while len(practice_objects) > 0:
            random_practice_index = random.randint(0,
                                                   len(practice_objects) - 1)
            practice_object = practice_objects[random_practice_index]

            random_step_count = self._get_random_step_count()
            produced_exercise = practice_object().get_exercise(
                random_step_count, guitar)
            if produced_exercise is not None:
                exercises.append(produced_exercise)
            practice_objects.pop(random_practice_index)

        output = workout.WorkOut(exercises)
        return output
Beispiel #2
0
 def _test_gcic(self):
     print("Testing get_classes_in_container")
     classes = Inspector.get_classes_in_container(self._container)
     for class_name in classes:
         print("- Found class: " + class_name.__module__)