Skip to content
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

[release] 0.8.2 #159

Merged
merged 6 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[fix] 개인 시간표 상 교수 이름이 없는 과목 처리 (#157)
# What's in this pull request
- 개인 시간표 상에 교수 이름이 없는 과목이 없을 경우 파싱에 실패하는 문제 해결
  • Loading branch information
EATSTEAK committed Dec 21, 2024
commit a40c2ec66699f387c9e537057c04012e015d90fc
42 changes: 24 additions & 18 deletions packages/rusaint/src/application/personal_course_schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,57 +103,63 @@ impl<'a> PersonalCourseScheduleApplication {
.for_each(|(col_idx, str)| match col_idx {
0 => {
schedule.entry(Weekday::Mon).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Mon)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
1 => {
schedule.entry(Weekday::Tue).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Tue)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
2 => {
schedule.entry(Weekday::Wed).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Wed)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
3 => {
schedule.entry(Weekday::Thu).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Thu)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
4 => {
schedule.entry(Weekday::Fri).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Fri)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
5 => {
schedule.entry(Weekday::Sat).or_default();
str.split("\n\n").for_each(|str| {
let mut iter = str.split("\n").peekable();
while iter.peek().is_some() {
schedule
.get_mut(&Weekday::Sat)
.unwrap()
.push(CourseScheduleInformation::from_string(str))
});
.push(CourseScheduleInformation::from_iter(&mut iter))
}
}
_ => {}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ pub struct CourseScheduleInformation {
}

impl CourseScheduleInformation {
pub(crate) fn from_string(str: &str) -> CourseScheduleInformation {
let mut splited = str.split("\n");
pub(crate) fn from_iter<'a>(
iter: &mut impl Iterator<Item = &'a str>,
) -> CourseScheduleInformation {
let mut iter = iter.skip_while(|s| s.is_empty());
// Consume empty strings at start
CourseScheduleInformation {
name: splited.next().unwrap().to_string(),
professor: splited.next().unwrap().to_string(),
time: splited.next().unwrap().to_string(),
classroom: splited.next().unwrap_or("").to_string(),
name: iter.next().unwrap().to_string(),
professor: iter.next().unwrap().to_string(),
time: iter.next().unwrap().to_string(),
classroom: iter.next().unwrap_or("").to_string(),
}
}

Expand Down