Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed May 10, 2013
2 parents 6f4019c + 42052d5 commit 06d8a81
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyshanb/iciba.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __query(self, word):
return None

def get_data(self, word):
"""获取单词简明释义,get_data(self, word) -> datas
"""获取单词简明释义
返回值:
(u'音节划分', u'audio url', ((u'词性', u'解释'),...), u'同义词之类的'))
Expand Down
35 changes: 23 additions & 12 deletions pyshanb/pyshanb.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,29 @@ def main():

while not sentence:
sentence = raw_input('Please input sentence:\n')
while not translation:
translation = raw_input('Please input translation:\n')
sentence = sentence.strip(' \n')
translation = translation.strip(' \n')
encoding = sys.stdin.encoding
translation = translation.decode(encoding).encode('utf8')

result = shanbay.add_example(api_add_example, word_learning_id,
quote(sentence),
quote(translation))
if result.get('example_status') == 1:
print 'Add success'
if sentence.strip(' \n').lower() == 'q':
sentence = None
break
if sentence:
while not translation:
translation = raw_input('Please input translation:\n')
if translation.strip(' \n').lower() == 'q':
translation = None
break
if sentence and translation:
sentence = sentence.strip(' \n')
translation = translation.strip(' \n')
encoding = sys.stdin.encoding
translation = translation.decode(encoding).encode('utf8')

result = shanbay.add_example(api_add_example,
word_learning_id,
quote(sentence),
quote(translation))
if result.get('example_status') == 1:
print 'Add success'
else:
pass

print '-' * cmd_width

Expand Down

0 comments on commit 06d8a81

Please sign in to comment.