Пример #1
0
    def get_active_directory_path(cls) -> str:
        if cls.__active_students_directory_path is None:
            cls.__active_students_directory_path = get_directory_path(
                "active/")
        if cls.__active_students_directory_path is None:
            config_path = get_config_path()
            print(f"Creating active directory in {config_path}")
            os.mkdir(f"{config_path}/active")
            cls.__active_students_directory_path = f"{config_path}/active"

        return cls.__active_students_directory_path
Пример #2
0
def create_student_pulls_directory(student) -> str:
    try:
        pulls_directory_path = get_directory_path("pulls/")
    except FileNotFoundError:
        pulls_directory_path = f"{get_local_config_path()}/pulls/"
        os.mkdir(pulls_directory_path)
    finally:
        student_pulls_directory_path = pulls_directory_path + student.file_name
        os.mkdir(student_pulls_directory_path)
        print(
            f"Creating pulls directory for {student.university_login} at {student_pulls_directory_path}"
        )
        return student_pulls_directory_path
Пример #3
0
def get_all_students(context: "Context") -> List["Student"]:
    from student.student import Student
    from core.config_loader import get_directory_path, get_config_path

    student_directory = ""
    try:
        student_directory = get_directory_path("active/")
    except FileNotFoundError:
        print("Creating active directory in localconfig")
        config_path = get_config_path()
        os.mkdir(f"{config_path}/active/")
        student_directory = f"{config_path}/active/"

    students = []
    for student_file in sorted(os.listdir(student_directory)):
        students.append(Student(context, university_login=student_file))

    return students
Пример #4
0
def get_local_pull_requests(
    context: Context,
    students: Optional[List["Student"]] = None,
    filters: Optional[Dict[str, Any]] = None,
) -> List["PullRequest"]:
    from student.student import StudentFactory
    from core.config_loader import get_directory_path

    if students is None:
        students = [
            StudentFactory.get_student(context, student_name)
            for student_name in os.listdir(get_directory_path("pulls/"))
        ]

    pulls = []
    for student in students:
        for student_pull_file in os.listdir(student.pulls_directory_path()):
            pr = context.get_pull_request(student_pull_file, student)
            if pr.passes_filters(filters):
                pulls.append(pr)

    return pulls
Пример #5
0
 def pulls_directory_path(self) -> str:
     try:
         return get_directory_path(f"pulls/{self.file_name}")
     except FileNotFoundError:
         return create_student_pulls_directory(self)