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

Commit 5b07fd8

Browse files
committed
FIX compatible bug
1 parent a5e09c7 commit 5b07fd8

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

NUAAiCal/GenerateICS.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ def create_ics(lessons, semester_start_date):
4949
event.add('dtstamp', datetime.now(tz=timezone('Asia/Shanghai')))
5050
event.add('location', lesson.room_number.rstrip() + '@' +
5151
lesson.school_distinct.rstrip())
52-
event.add('description', "教师:" + lesson.teacher_name.rstrip() +
52+
try:
53+
event.add('description', "教师:" + lesson.teacher_name.rstrip() +
5354
"\n" +
5455
"课程序号:" + lesson.lesson_order_number.rstrip()
5556
+ "\n\nPowered by <a href=\"https://github.com/Triple-Z/NUAA-iCal-Python\">NUAA-iCal-Python</a>")
57+
except UnicodeDecodeError:
58+
details = "教师:".decode('utf-8') + lesson.teacher_name.rstrip()\
59+
+ "\n".decode('utf-8') + \
60+
"课程序号:".decode('utf-8') +\
61+
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')
62+
event.add('description', details)
5663

5764
cal.add_component(event)
5865

NUAAiCal/main.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def main():
3535
print('学号: 你的南京航空航天大学学号')
3636
print("-------- 请填写以下信息 --------")
3737

38-
xn = input('学年: ')
38+
try:
39+
xn = input("学年: ")
40+
except UnicodeEncodeError:
41+
# fucking python 2.7 unicode
42+
xn = input("学年: ".encode('utf-8'))
3943

4044
if '-' in xn:
4145

@@ -48,11 +52,20 @@ def main():
4852
else:
4953

5054
if not settings.DEBUG:
51-
xq = input('学期: ')
55+
try:
56+
xq = input('学期: ')
57+
except UnicodeEncodeError:
58+
xq = input('学期: '.encode('utf-8'))
59+
5260
if not (xq == '1' or xq == '2'):
5361
print("学期输入错误! 提示:1为上学期,2为下学期!")
5462
exit()
55-
xh = input('学号: ')
63+
64+
try:
65+
xh = input('学号: ')
66+
except UnicodeEncodeError:
67+
xh = input('学号: '.encode('utf-8'))
68+
5669
print("==================================================")
5770

5871
semester_start_date = get_semester_start_date(years, xq, client)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
long_description = f.read()
1010
setup(
1111
name='NUAAiCal',
12-
version='0.4.1',
12+
version='0.4.2',
1313
description='Generate NUAA curriculum to iCalendar file.',
1414
url='https://github.com/Triple-Z/NUAA-iCal-Python',
1515
author='TripleZ',

0 commit comments

Comments
 (0)