-
Notifications
You must be signed in to change notification settings - Fork 17
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 issue #26 #31
fix issue #26 #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import aiofiles | ||
import aiohttp | ||
from tqdm import tqdm | ||
global droppedCourse | ||
droppedCourse={"courseIDs":[],"courseCodes":[]} | ||
|
||
__version__ = "2.0.5" | ||
CONFIG_PATH = os.path.join( | ||
|
@@ -187,6 +189,7 @@ async def getCourseIdByCourseCodeHelper(self, page, lowerCourseCodes): | |
if not courses: | ||
return res | ||
for course in courses: | ||
#print(course) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented debug lines should be deleted. |
||
if course.get("course_code", "").lower() in lowerCourseCodes: | ||
res[course["id"]] = course["course_code"] | ||
lowerCourseCodes.remove(course.get("course_code", "").lower()) | ||
|
@@ -208,10 +211,23 @@ async def getCourseIdByCourseCode(self): | |
endOfPage = True | ||
self.courseCode.update(item) | ||
page += PAGES_PER_TIME | ||
correct_courseCode = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unify the naming style with the project. Use camel case. |
||
for i in self.courseCode: | ||
correct_courseCode.append(self.courseCode[i]) | ||
for i in self.config["courseCodes"]: | ||
if i not in correct_courseCode: | ||
if i not in droppedCourse["courseCodes"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Combine consecutive |
||
print("course with course code",i,"might be dropped!") | ||
droppedCourse["courseCodes"].append(i) | ||
|
||
async def getCourseCodeByCourseIDHelper(self, courseID): | ||
url = f"{self.baseurl}/courses/{courseID}" | ||
sessRes = await self.sessGetJson(url) | ||
#print("this is sessRes:\n ",sessRes) | ||
if "id" not in sessRes.keys(): | ||
if courseID not in droppedCourse["courseIDs"]: | ||
print("Course with course ID",courseID,"might be dropped!") | ||
droppedCourse["courseIDs"].append(courseID) | ||
if sessRes.get("course_code") is None: | ||
return | ||
self.courseCode[courseID] = sessRes["course_code"] | ||
|
@@ -345,6 +361,7 @@ async def sync(self): | |
) | ||
|
||
|
||
|
||
def initConfig(): | ||
oldConfig = {} | ||
if os.path.exists(CONFIG_PATH): | ||
|
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.
Consider storing the value inside the class.