docs: 新增API使用範例註解
This commit is contained in:
parent
913f235dfc
commit
10f0b02938
30
main.py
30
main.py
@ -6,44 +6,74 @@ from api.ncnu import NCNU
|
|||||||
def space():
|
def space():
|
||||||
print("\n" + "="*20 + "\n")
|
print("\n" + "="*20 + "\n")
|
||||||
|
|
||||||
|
# =================== TEST Moodle API ==========================
|
||||||
|
|
||||||
|
# ===== Test 登入 =====
|
||||||
moodle = Moodle(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
moodle = Moodle(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||||
if moodle.status:
|
if moodle.status:
|
||||||
|
|
||||||
|
# ===== Test 取得該學期課程資料 =====
|
||||||
for c in moodle.getCourses("1092"):
|
for c in moodle.getCourses("1092"):
|
||||||
print(c)
|
print(c)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== Test 取得未來重要事件 =====
|
||||||
for e in moodle.getUpcomingEvents():
|
for e in moodle.getUpcomingEvents():
|
||||||
print(e)
|
print(e)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== Test 取得課程在當週發布的物件 ( 文件、功課、BBB連結... 等)
|
||||||
for work in moodle.getWeekWorkInCourse('47562'):
|
for work in moodle.getWeekWorkInCourse('47562'):
|
||||||
print(work)
|
print(work)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== TEST 取得該課程的最新公告
|
||||||
for anno in moodle.getAnnoInCourse('47555'):
|
for anno in moodle.getAnnoInCourse('47555'):
|
||||||
print(anno)
|
print(anno)
|
||||||
space()
|
space()
|
||||||
else:
|
else:
|
||||||
print("Moodle 登入失敗")
|
print("Moodle 登入失敗")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# =================== Test 暨大官網 API ==========================
|
||||||
|
|
||||||
|
# ===== Test 取得暨大官網最新消息 =====
|
||||||
main = NcnuMain()
|
main = NcnuMain()
|
||||||
for anno in main.getAnno():
|
for anno in main.getAnno():
|
||||||
print(anno)
|
print(anno)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# =================== Test 暨大教務系統 API ==========================
|
||||||
|
|
||||||
|
# ===== Test 登入 =====
|
||||||
ncnu = NCNU(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
ncnu = NCNU(CONFIG['NCNU']['username'], CONFIG['NCNU']['password'])
|
||||||
if ncnu.status:
|
if ncnu.status:
|
||||||
|
|
||||||
|
# ===== Test 下載課表 =====
|
||||||
if ncnu.getCourseTable('1092'):
|
if ncnu.getCourseTable('1092'):
|
||||||
print("1092 課表已經儲存到 ./1092課表.pdf")
|
print("1092 課表已經儲存到 ./1092課表.pdf")
|
||||||
else:
|
else:
|
||||||
print("無法存取 1092 課表")
|
print("無法存取 1092 課表")
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== Test 取得各學期成績總覽 =====
|
||||||
scores = ncnu.getScoreSummary()
|
scores = ncnu.getScoreSummary()
|
||||||
for c in scores['semesters']:
|
for c in scores['semesters']:
|
||||||
print(c)
|
print(c)
|
||||||
print(scores['sum'])
|
print(scores['sum'])
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== Test 取得指定學期的成績列表 =====
|
||||||
scores = ncnu.getScore('1092')
|
scores = ncnu.getScore('1092')
|
||||||
for i in scores:
|
for i in scores:
|
||||||
print(i)
|
print(i)
|
||||||
space()
|
space()
|
||||||
|
|
||||||
|
# ===== Test 取得所有缺曠課記錄 =====
|
||||||
absenceLogs = ncnu.getAbsenceLog()
|
absenceLogs = ncnu.getAbsenceLog()
|
||||||
if absenceLogs:
|
if absenceLogs:
|
||||||
for log in absenceLogs:
|
for log in absenceLogs:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user