| Conditions | 5 |
| Total Lines | 33 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python |
||
| 9 | def assemble_schedule(schedule_data): |
||
| 10 | """ 组装课表回复数据 """ |
||
| 11 | week_day_text = ['日', '一', '二', '三', '四', '五', '六'] |
||
| 12 | strf = "%Y年%m月%d日" |
||
| 13 | if six.PY2: |
||
| 14 | strf = strf.encode("utf-8")
|
||
| 15 | description = datetime.datetime.now().strftime(strf) |
||
| 16 | |||
| 17 | # 获取第一周 星期一 的课表 |
||
| 18 | weeks = 1 |
||
| 19 | what_day = 1 |
||
| 20 | articles = [{
|
||
| 21 | 'title': '第%d周-星期%s' % (weeks, week_day_text[what_day]), |
||
| 22 | 'description': description, |
||
| 23 | 'url': '' |
||
| 24 | }] |
||
| 25 | for i, section in enumerate(schedule_data['schedule'][what_day - 1]): |
||
| 26 | for c in section: |
||
| 27 | if weeks in c['weeks_arr']: |
||
| 28 | section_time = '第%d,%d节' % (i * 2 + 1, i * 2 + c['section']) |
||
| 29 | content = '%s 地点:%s\n课程:%s' % ( |
||
| 30 | section_time, c['place'], c['name']) |
||
| 31 | articles.append({
|
||
| 32 | 'title': content, |
||
| 33 | 'description': "", |
||
| 34 | 'url': '' |
||
| 35 | }) |
||
| 36 | articles.append({
|
||
| 37 | 'title': '点击这里:查看完整课表', |
||
| 38 | 'description': '', |
||
| 39 | 'url': 'https://open.dairoot.cn/get_schedule' |
||
| 40 | }) |
||
| 41 | return articles |
||
| 42 | |||
| 62 |