Skip to content

Commit

Permalink
수업 이름과 장소를 가릴 수 있는 옵션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sookcha committed Aug 29, 2023
1 parent 9f2005b commit 329f69a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def get_subjects(self):

return result

def get_calendar(self, timetable, start_date, end_date):
def get_calendar(self, timetable, start_date, end_date, hide_details=False):
cal = Calendar()

for item in timetable:
for time in item["info"]:
event = Event()
event.add('summary', item["name"])
event.add('summary', item["name"] if not hide_details else "수업")
event.add('dtstart', parser.parse("%s %s" % (self.get_nearest_date(start_date, time["day"]), time["startAt"])))
event.add('dtend', parser.parse("%s %s" % (self.get_nearest_date(start_date, time["day"]), time["endAt"])))
event.add('rrule', {'freq': 'WEEKLY', 'until': parser.parse(end_date)})
if time["place"] != "":
if time["place"] != "" and not hide_details:
event.add('location', time["place"])
cal.add_component(event)

Expand Down
3 changes: 2 additions & 1 deletion every2cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def main():
parser.add_argument("--begin", type=str, help="Semester beginning date", required=True)
parser.add_argument("--end", type=str, help="Semester ending date", required=True)
parser.add_argument("--output", type=str, help="Output file path", required=False)
parser.add_argument("--hide-details", action="store_true", help="Hide subject name", required=False)
args = parser.parse_args()

xml = ""
Expand All @@ -27,7 +28,7 @@ def main():
xml = e.get_timetable()

c = Convert(xml)
cal = c.get_calendar(c.get_subjects(), args.begin, args.end)
cal = c.get_calendar(c.get_subjects(), args.begin, args.end, args.hide_details)
output_path = args.output if (args.output) else os.path.join('', 'calendar.ics')
c.export_calender_as_ics(cal, output_path)

Expand Down

0 comments on commit 329f69a

Please sign in to comment.