Permalink
Browse files

Save words into one file.

  • Loading branch information...
1 parent a82482e commit 603e16229bcf372097e61491052a0d81b0886936 @svetlyak40wt committed Sep 12, 2011
Showing with 7 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 cony/__init__.py
  3. +5 −3 cony/repo/lang.py
View
@@ -8,3 +8,4 @@ dist/
local_settings.py
.vim/ide.session
build
+.commands
View
@@ -172,6 +172,7 @@ def __init__(self, source=None, name=None, **kwargs):
def do_command():
"""Runs a command"""
search_string = request.GET.get('s', 'help')
+ search_string = search_string.decode('utf-8')
tokens = search_string.split(' ', 1)
command_name = tokens[0]
View
@@ -17,14 +17,14 @@ def cmd_translate(term):
def cmd_save_word(term):
- """Saves word and it's translation into the ~/.words/YYYY-MM-DD.txt
+ """Saves word and it's translation into the ~/.words.csv
These files could be used to import words into the FlashCards ToGo.
"""
if ';' not in term:
return cmd_search_word(term)
- filename = datetime.datetime.now().strftime('~/.words/%Y-%m-%d.txt')
+ filename = '~/.words.csv'
template = """
<p>Translation "{{ word }}" was saved to %s</p>
@@ -62,9 +62,11 @@ def cmd_search_word(term):
variants = {}
for i in reversed(range((len(term) + 1) / 2, len(term) + 1)):
- url = 'http://suggest-slovari.yandex.ru/suggest-lingvo?v=2&lang=en&part=%s' % term[:i]
+ url = 'http://suggest-slovari.yandex.ru/suggest-lingvo?v=2&lang=en&' + \
+ urllib.urlencode(dict(part=term[:i].encode('utf-8')))
data = urllib.urlopen(url).read()
data = simplejson.loads(data)
+
if data[0]:
for trans, link in zip(*data[1:]):
en, ru = trans.split(' - ', 1)

0 comments on commit 603e162

Please sign in to comment.