from __future__ import annotations from collections import defaultdict from dataclasses import replace from datetime import date, datetime, timedelta import hashlib import json import re from pathlib import Path from typing import Iterable from .domain import ( ACCOUNT_STATUSES, AUTO_RECOGNITION_SOURCES, Account, ClassRecord, DuplicateRecordError, FALLBACK_ALIASES, HIGH_CONFIDENCE_VALUES, Payment, QuerySpec, ROLE_WORDS, SUBJECTS, SUBJECT_ALIASES, UNKNOWN_SUBJECTS, UNKNOWN_TEACHERS, WEEKDAYS, ) from .storage import atomic_write_text, create_data_backup, prune_data_backups CLASSNOTE_RE = re.compile( r"^(?P\d{4}\.\d{2}\.\d{2})-" r"(?P星期[一二三四五六日])-" r"(?P