Skip to content

Commit

Permalink
feat : 先把一批文件换成unicode的。。。
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoZeyuan committed Jan 14, 2017
1 parent 8eff2b6 commit 17b5140
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 139 deletions.
18 changes: 9 additions & 9 deletions src/command_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,51 +65,51 @@ def parse_command(raw_command=''):
@staticmethod
def parse_question(command):
result = Match.question(command)
question_id = result.group('question_id')
question_id = result.group(u'question_id')
task = QuestionTask(question_id)
return task

@staticmethod
def parse_answer(command):
result = Match.answer(command)
question_id = result.group('question_id')
answer_id = result.group('answer_id')
question_id = result.group(u'question_id')
answer_id = result.group(u'answer_id')
task = AnswerTask(question_id, answer_id)
return task

@staticmethod
def parse_author(command):
result = Match.author(command)
author_page_id = result.group('author_page_id')
author_page_id = result.group(u'author_page_id')
task = AuthorTask(author_page_id)
return task

@staticmethod
def parse_collection(command):
result = Match.collection(command)
collection_id = result.group('collection_id')
collection_id = result.group(u'collection_id')
task = CollectionTask(collection_id)
return task

@staticmethod
def parse_topic(command):
result = Match.topic(command)
topic_id = result.group('topic_id')
topic_id = result.group(u'topic_id')
task = TopicTask(topic_id)
return task

@staticmethod
def parse_article(command):
result = Match.article(command)
column_id = result.group('column_id')
article_id = result.group('article_id')
column_id = result.group(u'column_id')
article_id = result.group(u'article_id')
task = ArticleTask(column_id, article_id)
return task

@staticmethod
def parse_column(command):
result = Match.column(command)
column_id = result.group('column_id')
column_id = result.group(u'column_id')
task = ColumnTask(column_id)
return task

Expand Down
6 changes: 3 additions & 3 deletions src/container/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ def generate_book_info_page(self):
filename = self.get_random_html_file_name()
content = Template.book_info.format(
**{
'title': self.book_title
u'title': self.book_title
}
)
uri = Path.html_pool_path + '/' + filename
buf_file = open(uri, 'w')
uri = Path.html_pool_path + u'/' + filename
buf_file = open(uri, u'w')
buf_file.write(content)
buf_file.close()
return uri
Expand Down
8 changes: 4 additions & 4 deletions src/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_login_client(self):
print u'输入『yes』按回车更换其他账号'
print u'直接敲击回车获取验证码'
confirm = raw_input()
if confirm == 'yes':
if confirm == u'yes':
account, password = self.get_account()
captcha = self.get_captcha()
Config.save()
Expand Down Expand Up @@ -91,7 +91,7 @@ def login(self, account, password, captcha=None):
Config.account, Config.password, Config.remember_account = account, password, True
else:
print u'请问是否需要记住帐号密码?输入yes记住,输入其它任意字符跳过,回车确认'
if raw_input() == 'yes':
if raw_input() == u'yes':
Config.account, Config.password, Config.remember_account = account, password, True
print u'帐号密码已保存,可通过修改config.json修改设置'
else:
Expand All @@ -110,7 +110,7 @@ def __save_login_client(self):

def __clear_login_client(self):
u"""清空登录token"""
with open(Login.Login_Token_File_Uri, 'w') as token_file:
with open(Login.Login_Token_File_Uri, u'w') as token_file:
token_file.write('')
return

Expand All @@ -131,7 +131,7 @@ def get_captcha(self):

captcha_path = Path.base_path + u'/我是登陆知乎时的验证码.gif'

image = open(captcha_path, 'wb')
image = open(captcha_path, u'wb')
image.write(img_content_bytes)
image.close()

Expand Down
8 changes: 4 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def start(self):

Debug.logger.info(u"开始读取ReadList.txt设置信息")

if not Path.is_file('./ReadList.txt'):
if not Path.is_file(u'./ReadList.txt'):
# 当ReadList不存在的时候自动创建之
with open('./ReadList.txt', 'w') as read_list:
with open(u'./ReadList.txt', u'w') as read_list:
read_list.close()
print Debug.logger.info(u"ReadList.txt 内容为空,自动退出")
return
Expand All @@ -53,7 +53,7 @@ def start(self):
def read_list(self):
book_counter = 0 # 统计累计制作了多少本书籍
# 遍历ReadList,根据指令生成电子书
with open('./ReadList.txt', 'r') as read_list:
with open(u'./ReadList.txt', u'r') as read_list:
for line in read_list:
line = line.replace(' ', '').replace('\r', '').replace('\n', '').replace('\t', '').split('#')[0] # 移除空白字符
if len(line) == 0:
Expand Down Expand Up @@ -117,7 +117,7 @@ def check_update(): # 强制更新
try:
content = Http.get_content(u"https://www.yaozeyuan.online/zhihuhelp/upgrade.txt")
if not content:
raise Exception('HttpError')
raise Exception(u'HttpError')
time, url = [x.strip() for x in content.strip('\n').split('\n')]
if time == Config.update_time:
return
Expand Down
Loading

0 comments on commit 17b5140

Please sign in to comment.