import re
with open('generate_week9.py', 'r') as f:
content = f.read()
# Build the correct teacher guide call (matching Week 8 format)
tg_call = '''from teacher_guide import generate_teacher_guide
generate_teacher_guide(
week_dir=WEEK, week_num=9, phonics_label=PHONICS_LABEL, words=WORDS,
phonics_name="Prefixes: UN-, RE-, DIS-",
# Monday
monday_phonics_explanation=TEACHER_MONDAY_PHONICS_EXPLANATION,
monday_grammar_focus=TEACHER_MONDAY_GRAMMAR_FOCUS,
monday_grammar_explanation=TEACHER_MONDAY_GRAMMAR_EXPLANATION,
monday_story_text=MONDAY_STORY,
monday_sort_labels=TEACHER_MONDAY_SORT_LABELS,
monday_sort_answers=TEACHER_MONDAY_SORT_ANSWERS,
monday_fill_answers=TEACHER_MONDAY_FILL_ANSWERS,
monday_opposite_answers=TEACHER_MONDAY_OPPOSITE_ANSWERS,
monday_sentence_words=TEACHER_MONDAY_SENTENCE_WORDS,
# Tuesday
tuesday_phonics_explanation=TEACHER_TUESDAY_PHONICS_EXPLANATION,
tuesday_scramble_answers=TEACHER_TUESDAY_SCRAMBLE_ANSWERS,
tuesday_reading_text=TUESDAY_READING,
tuesday_comp_questions=TEACHER_TUESDAY_COMP_QUESTIONS,
tuesday_comp_answers=TEACHER_TUESDAY_COMP_ANSWERS,
tuesday_pattern_hunt_answers=TEACHER_TUESDAY_PATTERN_HUNT,
tuesday_swap_answers=TEACHER_TUESDAY_SWAP_ANSWERS,
tuesday_builder_prompts=TEACHER_TUESDAY_BUILDER_PROMPTS,
# Wednesday
wednesday_phonics_explanation=TEACHER_WEDNESDAY_PHONICS_EXPLANATION,
wednesday_reading_text=WEDNESDAY_READING,
wednesday_vocab_q_question=TEACHER_WEDNESDAY_VOCAB_Q_QUESTION,
wednesday_vocab_q_answer=TEACHER_WEDNESDAY_VOCAB_Q_ANSWER,
wednesday_syn_ant_words=TEACHER_WEDNESDAY_SYN_ANT_WORDS,
wednesday_word_web_center=TEACHER_WEDNESDAY_WORD_WEB_CENTER,
wednesday_word_web_suggestions=TEACHER_WEDNESDAY_WORD_WEB_SUGGESTIONS,
wednesday_sort_answers=TEACHER_WEDNESDAY_SORT_ANSWERS,
wednesday_correct_answers=TEACHER_WEDNESDAY_CORRECT_ANSWERS,
wednesday_fill_answers=TEACHER_WEDNESDAY_FILL_ANSWERS,
wednesday_context_clue_question=TEACHER_WEDNESDAY_CONTEXT_CLUE_QUESTION,
wednesday_context_clue_answer=TEACHER_WEDNESDAY_CONTEXT_CLUE_ANSWER,
wednesday_dictation_words=TEACHER_WEDNESDAY_DICTATION_WORDS,
# Thursday
thursday_phonics_explanation=TEACHER_THURSDAY_PHONICS_EXPLANATION,
thursday_story_text=THURSDAY_STORY,
thursday_comp_questions=TEACHER_THURSDAY_COMP_QUESTIONS,
thursday_comp_answers=TEACHER_THURSDAY_COMP_ANSWERS,
thursday_sort_answers=TEACHER_THURSDAY_SORT_ANSWERS,
thursday_detective_answers=TEACHER_THURSDAY_DETECTIVE_ANSWERS,
thursday_swap_answers=TEACHER_THURSDAY_SWAP_ANSWERS,
thursday_map_word=TEACHER_THURSDAY_MAP_WORD,
thursday_map_suggestions=TEACHER_THURSDAY_MAP_SUGGESTIONS,
thursday_para_prompts=TEACHER_THURSDAY_PARA_PROMPTS,
# Friday
friday_phonics_explanation=TEACHER_FRIDAY_PHONICS_EXPLANATION,
friday_test_answers=TEACHER_FRIDAY_TEST_ANSWERS,
friday_story_questions=TEACHER_FRIDAY_STORY_QUESTIONS,
friday_story_answers=TEACHER_FRIDAY_STORY_ANSWERS,
friday_opposite_answers=TEACHER_FRIDAY_OPPOSITE_ANSWERS,
friday_builder_words=TEACHER_FRIDAY_BUILDER_WORDS,
friday_journal_words=TEACHER_FRIDAY_JOURNAL_WORDS,
)
print("Teacher Guide generated.")'''
# Pattern to find the entire teacher guide block from import to print
pattern = r'from teacher_guide import generate_teacher_guide.*?print\("Teacher Guide generated\."\)'
if re.search(pattern, content, re.DOTALL):
content = re.sub(pattern, tg_call, content, flags=re.DOTALL)
with open('generate_week9.py', 'w') as f:
f.write(content)
print("SUCCESS: Replaced teacher guide call")
else:
print("ERROR: Pattern not found")