Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
FIX compatible bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Triple-Z committed Mar 2, 2018
1 parent a5e09c7 commit 5b07fd8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
9 changes: 8 additions & 1 deletion NUAAiCal/GenerateICS.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ def create_ics(lessons, semester_start_date):
event.add('dtstamp', datetime.now(tz=timezone('Asia/Shanghai')))
event.add('location', lesson.room_number.rstrip() + '@' +
lesson.school_distinct.rstrip())
event.add('description', "教师:" + lesson.teacher_name.rstrip() +
try:
event.add('description', "教师:" + lesson.teacher_name.rstrip() +
"\n" +
"课程序号:" + lesson.lesson_order_number.rstrip()
+ "\n\nPowered by <a href=\"https://github.com/Triple-Z/NUAA-iCal-Python\">NUAA-iCal-Python</a>")
except UnicodeDecodeError:
details = "教师:".decode('utf-8') + lesson.teacher_name.rstrip()\
+ "\n".decode('utf-8') + \
"课程序号:".decode('utf-8') +\
lesson.lesson_order_number.rstrip() + "\n\nPowered by <a href=\"https://github.com/Triple-Z/NUAA-iCal-Python\">NUAA-iCal-Python</a>".decode('utf-8')
event.add('description', details)

cal.add_component(event)

Expand Down
19 changes: 16 additions & 3 deletions NUAAiCal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def main():
print('学号: 你的南京航空航天大学学号')
print("-------- 请填写以下信息 --------")

xn = input('学年: ')
try:
xn = input("学年: ")
except UnicodeEncodeError:
# fucking python 2.7 unicode
xn = input("学年: ".encode('utf-8'))

if '-' in xn:

Expand All @@ -48,11 +52,20 @@ def main():
else:

if not settings.DEBUG:
xq = input('学期: ')
try:
xq = input('学期: ')
except UnicodeEncodeError:
xq = input('学期: '.encode('utf-8'))

if not (xq == '1' or xq == '2'):
print("学期输入错误! 提示:1为上学期,2为下学期!")
exit()
xh = input('学号: ')

try:
xh = input('学号: ')
except UnicodeEncodeError:
xh = input('学号: '.encode('utf-8'))

print("==================================================")

semester_start_date = get_semester_start_date(years, xq, client)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
long_description = f.read()
setup(
name='NUAAiCal',
version='0.4.1',
version='0.4.2',
description='Generate NUAA curriculum to iCalendar file.',
url='https://github.com/Triple-Z/NUAA-iCal-Python',
author='TripleZ',
Expand Down

0 comments on commit 5b07fd8

Please sign in to comment.