PhotonQuantum / pysjtu

The Python iSJTU client for Humans.
https://pysjtu.readthedocs.io/en/latest/
GNU General Public License v3.0
44 stars 3 forks source link

'zhxs' field may be a float #8

Closed truc0 closed 1 year ago

truc0 commented 1 year ago

The course 形势与政策 in 2022 Fall has a float value (.5) in zhxs field of course. The course data is provided at the end.

The field hour_week, which is corresponding to zhxs, has the type int in model Schedule. An error will occur when trying to load the course data to model.

A minimal reproduction:

import pysjtu
import json

with open('course.json') as f:  # course.json is the json listed at the end
    course = json.load(f)
s = pysjtu.models.Schedule(2022, 0)
s.load([course])

The traceback:

Traceback (most recent call last):
  File "/home/truco/expr/py/main.py", line 11, in <module>
    s.load([course])
  File "/home/truco/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pysjtu/models/base.py", line 192, in load
    results = schema.load(data)
  File "/home/truco/.pyenv/versions/3.9.6/lib/python3.9/site-packages/marshmallow/schema.py", line 722, in load
    return self._do_load(
  File "/home/truco/.pyenv/versions/3.9.6/lib/python3.9/site-packages/marshmallow/schema.py", line 909, in _do_load
    raise exc
marshmallow.exceptions.ValidationError: {0: {'zhxs': ['Not a valid integer.']}}

The course data:

{
  "bklxdjmc": "无",
  "cd_id": "ZY411",
  "cdmc": "中院411",
  "cxbj": "0",
  "cxbjmc": "无",
  "date": "二○二二年十二月二十一日",
  "dateDigit": "2022年12月21日",
  "dateDigitSeparator": "2022-12-21",
  "day": "21",
  "jc": "9-10节",
  "jcor": "9-10",
  "jcs": "9-10",
  "jgh_id": "10133",
  "jgpxzd": "1",
  "jxb_id": "E59F21516125D00CE055F8163EE1DCCC",
  "jxbmc": "(2022-2023-1)-MARX1205-99",
  "jxbzc": "电院2300",
  "kcbj": "主修",
  "kch": "MARX1205",
  "kch_id": "MARX1205",
  "kclb": "公共课程类",
  "kcmc": "形势与政策",
  "kcxszc": "理论:8",
  "kcxz": "必修",
  "kczxs": "8",
  "khfsmc": "考试",
  "kkzt": "1",
  "listnav": "false",
  "localeKey": "zh_CN",
  "month": "12",
  "oldjc": "768",
  "oldzc": "20752",
  "pageTotal": 0,
  "pageable": true,
  "pkbj": "1",
  "queryModel": {
    "currentPage": 1,
    "currentResult": 0,
    "entityOrField": false,
    "limit": 15,
    "offset": 0,
    "pageNo": 0,
    "pageSize": 15,
    "showCount": 10,
    "sorts": [],
    "totalCount": 0,
    "totalPage": 0,
    "totalResult": 0
  },
  "rangeable": true,
  "rk": "8",
  "rsdzjs": 0,
  "skfsmc": "中文",
  "sxbj": "1",
  "totalResult": "0",
  "userModel": {
    "monitor": false,
    "roleCount": 0,
    "roleKeys": "",
    "roleValues": "",
    "status": 0,
    "usable": false
  },
  "xf": "0.5",
  "xkbz": "腾讯会议号:hidden,密码:hidden",
  "xm": "教师姓名",
  "xnm": "2022",
  "xqdm": "0",
  "xqh1": "02,",
  "xqh_id": "02",
  "xqj": "3",
  "xqjmc": "星期三",
  "xqm": "3",
  "xqmc": "闵行",
  "xsdm": "01",
  "xslxbj": "◇",
  "year": "2022",
  "zcd": "5周,9周,13-15周(单)",
  "zcmc": "助理研究员(高教管理)",
  "zfjmc": "主讲",
  "zhxs": ".5",
  "zxs": "8",
  "zxxx": "无",
  "zyfxmc": "无方向",
  "zzrl": "91"
}
PhotonQuantum commented 1 year ago

Thanks for your report! I'm pushing a fix on this.

PhotonQuantum commented 1 year ago

A new version has been published at https://pypi.org/project/pysjtu/0.3.5/.