xdufacool/score_helper.py
def organize(classes, homework, **kwargs):
    """Organize homeworks donwloaded from baidu for archival."""
    fields = [kwargs["sid_xdu"]]
    student_classes = {}
    for cls in classes:
        class_name = cls.split(".")[0]
        if not os.path.exists(class_name):
            os.mkdir(class_name)
        hw_path = os.path.join(class_name, homework)
        if not os.path.exists(hw_path):
            os.mkdir(hw_path)
        data = load_xls(cls)
        sid_col, = find_column_index(data[0], fields)
        for row in data[1:]:
            sid = row[sid_col]
            student_classes[sid] = class_name

    for path, _, files in os.walk(homework):
        for name in files:
            if ".pdf" == name[-4:].lower():
                the_sid = name.split(".")[0].split("-")[-1]
                if the_sid in student_classes:
                    the_cls = student_classes[the_sid]
                    hw_src = os.path.join(path, name)
                    hw_dst = os.path.join(the_cls, homework, name)
                    # print(f"Copying {hw_src} to {hw_dst}...")
                    shutil.copyfile(hw_src, hw_dst)
                else:
                    print(f"Cannot find the class for student {the_sid}.")
Organize homeworks donwloaded from baidu for archival.
Organize homeworks donwloaded from baidu for archival.
Organize homeworks donwloaded from baidu for archival .
def organize(classes, homework, **kwargs):
    fields = [kwargs["sid_xdu"]]
    student_classes = {}
    for cls in classes:
        class_name = cls.split(".")[0]
        if not os.path.exists(class_name):
            os.mkdir(class_name)
        hw_path = os.path.join(class_name, homework)
        if not os.path.exists(hw_path):
            os.mkdir(hw_path)
        data = load_xls(cls)
        sid_col, = find_column_index(data[0], fields)
        for row in data[1:]:
            sid = row[sid_col]
            student_classes[sid] = class_name
    for path, _, files in os.walk(homework):
        for name in files:
            if ".pdf" == name[-4:].lower():
                the_sid = name.split(".")[0].split("-")[-1]
                if the_sid in student_classes:
                    the_cls = student_classes[the_sid]
                    hw_src = os.path.join(path, name)
                    hw_dst = os.path.join(the_cls, homework, name)
                    shutil.copyfile(hw_src, hw_dst)
                else:
                    print(f"Cannot find the class for student {the_sid}.")
def organize ( classes , homework , ** kwargs ) : fields = [ kwargs [ "sid_xdu" ] ] student_classes = { } for cls in classes : class_name = cls . split ( "." ) [ 0 ] if not os . path . exists ( class_name ) : os . mkdir ( class_name ) hw_path = os . path . join ( class_name , homework ) if not os . path . exists ( hw_path ) : os . mkdir ( hw_path ) data = load_xls ( cls ) sid_col , = find_column_index ( data [ 0 ] , fields ) for row in data [ 1 : ] : sid = row [ sid_col ] student_classes [ sid ] = class_name for path , _ , files in os . walk ( homework ) : for name in files : if ".pdf" == name [ - 4 : ] . lower ( ) : the_sid = name . split ( "." ) [ 0 ] . split ( "-" ) [ - 1 ] if the_sid in student_classes : the_cls = student_classes [ the_sid ] hw_src = os . path . join ( path , name ) hw_dst = os . path . join ( the_cls , homework , name ) shutil . copyfile ( hw_src , hw_dst ) else : print ( f"Cannot find the class for student {the_sid}." )
Organize homeworks donwloaded from baidu for archival.
Organize homeworks donwloaded from baidu for archival .
"""Organize homeworks donwloaded from baidu for archival.""" # print(f"Copying {hw_src} to {hw_dst}...")
classes
homework