-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kyle-seongwoo-jun/master
- Loading branch information
Showing
2 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
__author__ = "Hoseong Son <[email protected]>" | ||
|
||
import datetime | ||
import os | ||
import xml.etree.ElementTree as ElementTree | ||
from dateutil import parser | ||
from icalendar import Calendar, Event | ||
|
@@ -55,11 +54,11 @@ def get_calendar(self, timetable, start_date, end_date): | |
event.add('location', time["place"]) | ||
cal.add_component(event) | ||
|
||
f = open(os.path.join('', 'calendar.ics'), 'wb') | ||
f.write(cal.to_ical()) | ||
f.close() | ||
|
||
print("작업 완료!🙌") | ||
return cal | ||
|
||
def export_calender_as_ics(self, cal, path): | ||
with open(path, 'wb') as f: | ||
f.write(cal.to_ical()) | ||
|
||
def get_nearest_date(self, start_date, weekday): | ||
start_date = parser.parse(start_date) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,28 +3,36 @@ | |
__author__ = "Hoseong Son <[email protected]>" | ||
|
||
import argparse | ||
import os | ||
|
||
from convert import Convert | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--id", type=str, help="Everytime timetable id", required=False) | ||
parser.add_argument("--xml", type=str, help="Location of timetable xml file", required=False) | ||
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) | ||
args = parser.parse_args() | ||
|
||
xml = "" | ||
if (args.xml): | ||
xml = args.xml | ||
else: | ||
path = input('경로 : ') | ||
path = args.id if (args.id) else input('경로 : ') | ||
|
||
e = everytime.Everytime(path) | ||
xml = e.get_timetable() | ||
|
||
c = Convert(xml) | ||
c.get_calendar(c.get_subjects(), args.begin, args.end) | ||
cal = c.get_calendar(c.get_subjects(), args.begin, args.end) | ||
output_path = args.output if (args.output) else os.path.join('', 'calendar.ics') | ||
c.export_calender_as_ics(cal, output_path) | ||
|
||
print("작업 완료!🙌") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
main() |