-
Notifications
You must be signed in to change notification settings - Fork 0
/
keywordConf.py
60 lines (49 loc) · 1.82 KB
/
keywordConf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# configure for keywords
# -*- coding: utf-8 -*-
import os
import sys
from common import Common
class KeywordConfig(object):
"""A simple class for Keyword Configure"""
# Wiki 关键字 或者 关键词语
keyword = ''
# 关键字 关联的 wiki html文件
keyword_wiki_file = ''
#
absolute_keyword_wiki_file = ''
def __init__(self, kw):
self.keyword = kw
if Common.language == 'CHINESE':
self.keyword_wiki_file = self.keyword + Common.CN_suffix
elif Common.language == 'ENGLISH':
self.keyword_wiki_file = self.keyword + Common.EN_suffix
else:
print 'Language Error!'
sys.exit(-1)
print 'keyword: ', self.keyword
print 'wiki_file: ', self.keyword_wiki_file
def printKeyword(self, kw):
print self.keyword
# 检测 关键字wiki页面是否已存在
def CheckKeywordDownloadedWikiFile(self):
absolute_path = os.path.join(os.getcwd(), Common.downloadWikiFiles_path)
print absolute_path
if os.path.exists(absolute_path):
absolute_file_path = os.path.join(absolute_path, self.keyword_wiki_file)
# print absolute_file_path
unicode_absolute_file_path = absolute_file_path.decode('utf-8')
# print unicode_absolute_file_path
if os.path.isfile(unicode_absolute_file_path):
self.absolute_keyword_wiki_file = unicode_absolute_file_path
print 'Keyword Wiki File Existed!'
return True
else:
print 'Keyword Wiki File Not Existed!'
return False
else:
print 'DownloadedWikiFiles Path Not Existed!'
return False
#
if __name__=='__main__':
kc = KeywordConfig('梨')
kc.CheckKeywordDownloadedWikiFile()