Rev 136 | Rev 138 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
46 | szabot | 1 | #!/usr/bin/python |
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import tornado.database |
||
5 | import re |
||
6 | |||
7 | def getnavilist(): |
||
8 | ret = [] |
||
9 | current = u"" |
||
10 | db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
||
11 | for row in db.query(""" |
||
103 | szabot | 12 | SELECT * |
46 | szabot | 13 | FROM `metaWords` |
103 | szabot | 14 | WHERE partOfSpeech <> 'num.' AND partOfSpeech <> "prefix" |
15 | ORDER BY CHAR_LENGTH(navi) DESC"""): |
||
65 | szabot | 16 | if row["infixes"]: |
89 | szabot | 17 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]}) |
65 | szabot | 18 | else: |
89 | szabot | 19 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]}) |
46 | szabot | 20 | db.close() |
21 | return ret |
||
22 | |||
23 | def getnavi(word): |
||
24 | ret = [] |
||
25 | db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
||
26 | for row in db.query(""" |
||
27 | SELECT * |
||
28 | FROM `metaWords` |
||
29 | WHERE navi = ?""",word): |
||
65 | szabot | 30 | if row["infixes"]: |
89 | szabot | 31 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]}) |
65 | szabot | 32 | else: |
89 | szabot | 33 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]}) |
46 | szabot | 34 | db.close() |
136 | muzer | 35 | return ret |
36 | |||
137 | muzer | 37 | def translate(id,language): |
136 | muzer | 38 | db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
39 | for row in db.query(""" |
||
40 | SELECT * |
||
41 | FROM `localizedWords` |
||
137 | muzer | 42 | WHERE id = ? AND languageCode = ?""",id,language): |
136 | muzer | 43 | ret = row["localized"] |
44 | db.close() |
||
45 | return ret |