Пример #1
0
def write_class_sections(class_sections):
    SharedData.CLASS_SECTIONS = class_sections

    class_sections_json = []

    for class_section in class_sections:
        class_sections_json.append(class_section.to_json())

    path = SharedData.get_class_sections_data()
    with open(path, "w") as _file:
        json.dump(class_sections_json, _file, indent=2)
Пример #2
0
def load_class_sections() -> list:
    SharedData.CLASS_SECTIONS.clear()
    path = SharedData.get_class_sections_data()
    if not os.path.exists(path):
        return []

    with open(path, "r") as class_sections_file:
        class_sections_json = json.load(class_sections_file)

    for class_section in class_sections_json:
        SharedData.CLASS_SECTIONS.append(ClassSection.from_json(class_section))

    return SharedData.CLASS_SECTIONS