Esempio n. 1
0
def get_worklist(context: Context) -> List[Worklist]:
    try:
        worklist_filepath = get_file_path("worklist.yaml")
    except FileNotFoundError:
        raise GLMException("worklist.yaml doesn't exists",
                           "You first need to create worklist")

    with open(worklist_filepath) as file:
        parsed_worklist = yaml.safe_load(file)

    worklist = list()

    parsed_worklist_lines = set()

    for line in parsed_worklist:
        if line in parsed_worklist_lines:
            print(warn | f"Duplicity found, {line} has already been parsed")
            continue
        else:
            parsed_worklist_lines.add(line)

        worklist_line = parse_worklist_line(context, line)
        if worklist_line is not None:
            worklist.append(worklist_line)

    return worklist
Esempio n. 2
0
 def report_file_name(self) -> str:
     if not hasattr(self, "__report_file_name"):
         try:
             self.__report_file_name = read_line_file(
                 get_file_path(Filenames.REPORT_FILENAME.value))
         except FileNotFoundError:
             self.__report_file_name = "report.txt"
     return self.__report_file_name
Esempio n. 3
0
 def remote_report_branch_name(self) -> str:
     if not hasattr(self, "__remote_report_branch_name"):
         try:
             self.__remote_report_branch_name = read_line_file(
                 get_file_path(Filenames.REMOTE_REPORT_BRANCH_NAME.value))
         except FileNotFoundError:
             self.__remote_report_branch_name = "report"
     return self.__remote_report_branch_name
Esempio n. 4
0
def delete_student(student: "Student", quite: Optional[bool] = False):
    try:
        student_file_path = get_file_path(f"/active/{student.file_name}")
        os.remove(student_file_path)
        if not quite:
            print(f"Student {student.university_login} removed from active students")
    except FileNotFoundError as error:
        raise StudentDeleteException(
            f"Cannot find file for {student.university_login}",
            "There is something very wrong try running health check",
        ) from error
    except PermissionError as error:
        raise StudentDeleteException(
            f"Cannot delete {student_file_path}",
            f"Change permission on {student_file_path} with chmod",
        ) from error
Esempio n. 5
0
    def template_repository_name(self) -> str:
        if (not hasattr(self, "__template_repository_name")
                or self.__template_repository_name is None):
            try:
                template_repository_name_file_path = get_file_path(
                    Filenames.TEMPLATE_REPOSITORY_NAME.value)
                template_repository_name = read_line_file(
                    template_repository_name_file_path)
            except FileNotFoundError:
                raise ConfigFileException(
                    "File 'template_repository_name' was not found",
                    "Create template_repository_name file in localconfig or config directory",
                    True,
                )
            self.__template_repository_name = template_repository_name

        return self.__template_repository_name
Esempio n. 6
0
    def organization_name(self) -> str:
        if not hasattr(
                self,
                "__organization_name") or self.__organization_name is None:
            try:
                organization_name_file_path = get_file_path(
                    Filenames.ORGANIZATION_NAME.value)
                organization_name = read_line_file(organization_name_file_path)
                self.__organization_name = organization_name
            except FileNotFoundError:
                raise ConfigFileException(
                    "File 'organization_name' was not found",
                    "Create organization_name file in localconfig or config directory",
                    True,
                )

        return self.__organization_name
Esempio n. 7
0
    def user_repository_prefix(self) -> str:
        if (not hasattr(self, "__user_repository_prefix")
                or self.__user_repository_prefix is None):
            try:
                user_repository_prefix_file_path = get_file_path(
                    Filenames.USER_REPOSITORY_PREFIX.value)
                user_repository_prefix = read_line_file(
                    user_repository_prefix_file_path)
            except FileNotFoundError:
                raise ConfigFileException(
                    "File 'user_repository_prefix' was not found",
                    "Create user_repository_prefix file in localconfig or config directory",
                    True,
                )

            self.__user_repository_prefix = user_repository_prefix

        return self.__user_repository_prefix