forked from dairoot/school-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
61 lines (55 loc) · 1.86 KB
/
utils.py
File metadata and controls
61 lines (55 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# encoding: utf-8
from __future__ import absolute_import, unicode_literals
import six
import datetime
def assemble_schedule(schedule_data):
""" 组装课表回复数据 """
week_day_text = ['日', '一', '二', '三', '四', '五', '六']
strf = "%Y年%m月%d日"
if six.PY2:
strf = strf.encode("utf-8")
description = datetime.datetime.now().strftime(strf)
# 获取第一周 星期一 的课表
weeks = 1
what_day = 1
articles = [{
'title': '第%d周-星期%s' % (weeks, week_day_text[what_day]),
'description': description,
'url': ''
}]
for i, section in enumerate(schedule_data['schedule'][what_day - 1]):
for c in section:
if weeks in c['weeks_arr']:
section_time = '第%d,%d节' % (i * 2 + 1, i * 2 + c['section'])
content = '%s 地点:%s\n课程:%s' % (
section_time, c['place'], c['name'])
articles.append({
'title': content,
'description': "",
'url': ''
})
articles.append({
'title': '点击这里:查看完整课表',
'description': '',
'url': 'https://open.dairoot.cn/get_schedule?'
})
return articles
def assemble_score(score_year, score_term, score_data):
articles = [{
'title': '期末成绩单',
'description': '【第%s学年第%s学期】' % (score_year, score_term)
}]
for n, c in enumerate(score_data):
if n > 5:
break
print(c)
articles.append({
'title': "课程:%s\n学分:%s 成绩:%s" % (c['lesson_name'], c['credit'], c['score']),
})
articles.append({
'title': '点击这里:查看完整成绩',
'description': '',
'url': ''
})
return articles