def find(self, code):

        seekSummary = SeekOffsetCalculator.determineSeekValueAndOffset(
            self.lessonFileIndex, code)
        jumpToSeekValue = seekSummary["jumpToSeekValue"]
        currentLessonOffset = seekSummary["currentRecordOffset"]

        with FileReader.open(self.filePath) as file:
            file.seek(jumpToSeekValue)
            currentLessonLines = file.read(currentLessonOffset)
            print("*** Ders Kaydı ***")
            print(currentLessonLines)
    def find(self, no):

        if no < 0:
            print("Record is not a student!")
            return
        
        seekSummary = SeekOffsetCalculator.determineSeekValueAndOffset(self.studentFileIndex, no)
        jumpToSeekValue = seekSummary["jumpToSeekValue"]
        currentStudentOffset = seekSummary["currentRecordOffset"]

        with FileReader.open(self.filePath) as file:
            file.seek(jumpToSeekValue)
            currentStudentLines = file.read(currentStudentOffset)
            print("*** Öğrenci Kaydı ***")
            print(currentStudentLines)
    def update(self, no):

        if no < 0:
            print("Record is not a student!")
            return

        seekSummary = SeekOffsetCalculator.determineSeekValueAndOffset(self.studentFileIndex, no)
        jumpToSeekValue = seekSummary["jumpToSeekValue"]
        currentStudentOffset = seekSummary["currentRecordOffset"]

        firstPartLines = []
        lastPartLines = []
        with FileReader.open(self.filePath) as file:
            file.seek(0)
            firstPartLines = file.read(jumpToSeekValue).splitlines()
            print(firstPartLines)
            file.seek(currentStudentOffset + jumpToSeekValue)
            lastPartLines = file.read().splitlines()
            print(lastPartLines)


        with FileWriter.reset(self.filePath) as file:
            file.seek(0)
            if len(firstPartLines) > 0:
                content = ""
                for line in firstPartLines:
                    content += line + "\n"
                file.writelines(content)


        with FileWriter.update(self.filePath) as file:
            file.seek(jumpToSeekValue)
            student = StudentRecorder.create()
            studentSummary = student.prepareSummaryAsWritableFormat()
            file.write(studentSummary)
            newStudentOffSetValue = len(studentSummary)
            self.studentFileIndex[student.no] = newStudentOffSetValue
            print("Öğrenci başarıyla güncellendi.")
        
        with FileWriter.open(self.filePath) as file:
            content = ""
            for line in lastPartLines:
                content += line + "\n"
            file.writelines(content)
    def update(self, code):

        print(self.lessonFileIndex)
        seekSummary = SeekOffsetCalculator.determineSeekValueAndOffset(
            self.lessonFileIndex, code)
        jumpToSeekValue = seekSummary["jumpToSeekValue"]
        currentLessonOffset = seekSummary["currentRecordOffset"]

        firstPartLines = []
        lastPartLines = []
        with FileReader.open(self.filePath) as file:
            file.seek(0)
            firstPartLines = file.read(jumpToSeekValue).splitlines()
            print(firstPartLines)
            file.seek(currentLessonOffset + jumpToSeekValue)
            lastPartLines = file.read().splitlines()
            print(lastPartLines)

        with FileWriter.reset(self.filePath) as file:
            file.seek(0)
            if len(firstPartLines) > 0:
                content = ""
                for line in firstPartLines:
                    content += line + "\n"
                file.writelines(content)

        with FileWriter.update(self.filePath) as file:
            file.seek(jumpToSeekValue)
            lesson = LessonRecorder.create()
            lessonSummary = lesson.prepareSummaryAsWritableFormat()
            file.write(lessonSummary)
            newLessonOffSetValue = len(lessonSummary)
            self.lessonFileIndex[lesson.code] = newLessonOffSetValue
            print("Ders başarıyla güncellendi.")

        with FileWriter.open(self.filePath) as file:
            content = ""
            for line in lastPartLines:
                content += line + "\n"
            file.writelines(content)
 def __init__(self):
     if path.isfile(self.filePath):
         with FileReader.open(self.filePath) as file:
             SeekOffsetCalculator.createRecordFileIndex(self.studentFileIndex, file, 4)