-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some issues to work on my ceiba #16
base: master
Are you sure you want to change the base?
Conversation
…ith '公佈全班' attribute, and comment out some assertions base on my course list
ceiba_dl/vfs.py
Outdated
@@ -641,144 +643,160 @@ def fetch(self): | |||
assert len(student_page.xpath('//table')) > 0 | |||
|
|||
student_rows = student_page.xpath('//div[@id="sect_cont"]/table/tr') | |||
assert len(student_rows) == 12 | |||
# NTNU and NTUST students may have less rows | |||
#assert len(student_rows) == 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成<=?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryucc Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我其實有點好奇你遇到的是什麼狀況,不知道能不能貼個截圖(去除個資)當作參考,同時也讓之後看到這個 pull request 的人能更了解這個問題?我目前看過的 ntnu_* 和 ntust_* 帳號都和普通的臺大帳號一樣有 12 列,不知道是不是只有特定帳號有這個情形。
抱歉過了這麼久才回來看,有些關於 commit 的問題希望可以先解決:
|
@@ -10,6 +10,8 @@ | |||
import pycurl | |||
import urllib.parse | |||
|
|||
from pathvalidate import sanitize_filepath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
請仿照其他檔案,把所有的 from ... import ...
排在一起,並照字母排序。
由於 pathvalidate
不在 Python 標準函式庫中,需要額外安裝才能使用,因此請一併修改 README.asciidoc
、configure.ac
、requirements.txt
讓使用者知道這件事。
@@ -283,7 +286,8 @@ def download_link(self, path, node, retry, dcb, ecb): | |||
|
|||
def download_regular(self, path, node, retry, dcb, ecb): | |||
disk_path_object = pathlib.Path(path.lstrip('/')) | |||
|
|||
disk_path_object = pathlib.Path(sanitize_filepath(str(disk_path_object))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如同我在 #15 (comment) 所說,我覺得這個可以移入 disk_path_object_open
,只在檔名真的造成問題的時候才使用 sanitize_filepath
。至於特殊字元的處理方式,我覺得可以比照現在 /
替換成 _
的模式,看是要替換成 _
還是其他相似或全形的符號,而不要直接刪除。
@@ -283,7 +286,8 @@ def download_link(self, path, node, retry, dcb, ecb): | |||
|
|||
def download_regular(self, path, node, retry, dcb, ecb): | |||
disk_path_object = pathlib.Path(path.lstrip('/')) | |||
|
|||
disk_path_object = pathlib.Path(sanitize_filepath(str(disk_path_object))) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
請刪除行尾空白。
@@ -90,6 +90,7 @@ class Config: | |||
'attr_course_grades_show': '成績公布', | |||
'value_course_grades_show_n': '不公布', | |||
'value_course_grades_show_p': '公布個人', | |||
'value_course_grades_show_a': '公布全班', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個 commit 只增加設定值而無實際使用,是不是應該把「公布全班」相關的修改移來這個 commit,或是把這個 commit 併入下個 commit?理想上我們會希望每個 commit 都是一個完整、有意義、可以測試的修改。
@@ -353,6 +353,8 @@ def _create_course_list_map(self): | |||
course_list_page = self.vfs.request.web('/student/index.php') | |||
course_list_rows_all = course_list_page.xpath('//table[1]/tr') | |||
course_list_rows = course_list_rows_all[1:] | |||
# Add 旁聽 courses | |||
course_list_rows += course_list_page.xpath('//table[2]/tr')[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如同我在 #13 (comment) 所說,這樣的修改對不曾旁聽過任何課程的學生會有問題。
ceiba_dl/vfs.py
Outdated
@@ -641,144 +643,160 @@ def fetch(self): | |||
assert len(student_page.xpath('//table')) > 0 | |||
|
|||
student_rows = student_page.xpath('//div[@id="sect_cont"]/table/tr') | |||
assert len(student_rows) == 12 | |||
# NTNU and NTUST students may have less rows | |||
#assert len(student_rows) == 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我其實有點好奇你遇到的是什麼狀況,不知道能不能貼個截圖(去除個資)當作參考,同時也讓之後看到這個 pull request 的人能更了解這個問題?我目前看過的 ntnu_* 和 ntust_* 帳號都和普通的臺大帳號一樣有 12 列,不知道是不是只有特定帳號有這個情形。
@@ -795,7 +813,8 @@ def fetch(self): | |||
assert set(result.keys()) == set(result_keys) | |||
|
|||
days = '一二三四五六日' | |||
slots = '01234@56789XABCD' # 節次 (possible time slots: See https://nol.ntu.edu.tw/nol/guest/index.php for more information) | |||
#slots = '01234@56789XABCD' # 節次 (possible time slots: See https://nol.ntu.edu.tw/nol/guest/index.php for more information) | |||
slots = '01234@56789XABCD ' # For me, 暑期實習 has slot with space character |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
除非舊版的程式碼未來很可能會恢復使用,不然請不要用註解的方式刪除或修改程式碼。要刪就直接刪掉,要改也直接改掉,想看舊版的人可以自己去翻 git log。以這裡來說,你可以把舊的註解移到上面一行,再加上你這裡寫的新註解。註解中的「For me」看起來不太必要,其他人可能不看 git log 大概也不知道這裡的「me」是誰。
@@ -3121,7 +3146,8 @@ def __init__(self, vfs, parent, cell): | |||
def fetch(self): | |||
s = self.vfs.strings | |||
|
|||
assert not element_get_text(self._cell).strip() | |||
# I have a course which only has it assistants' names in '課程助教' column with pure text | |||
#assert not element_get_text(self._cell).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上面所說,不建議用註解的方式來刪除程式。另外以這裡來說,你應該會想要把名字記下來而不是直接忽略。
@@ -644,7 +644,7 @@ def fetch(self): | |||
|
|||
student_rows = student_page.xpath('//div[@id="sect_cont"]/table/tr') | |||
# NTNU and NTUST students may have less rows | |||
#assert len(student_rows) == 12 | |||
assert len(student_rows) <= 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這看起來是個 fixup commit,應該直接併入上一個 commit。
I fixed some issues in your project and removed some assertion based on my ceiba courses.
New features
pathvalidate
Unexpected conditions on my ceiba