Rev 145 | Rev 235 | 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 -*- |
||
| 176 | muzer | 3 | # This file is part of Tsim Apiak. |
| 4 | # |
||
| 5 | # Tsim Apiak is free software: you can redistribute it and/or modify |
||
| 6 | # it under the terms of the GNU General Public Licence as published by |
||
| 7 | # the Free Software Foundation, either version 3 of the Licence, or |
||
| 8 | # (at your option) any later version. |
||
| 9 | # |
||
| 10 | # In addition to this, you must also comply with clause 4 of the |
||
| 11 | # Apache Licence, version 2.0, concerning attribution. Where there |
||
| 12 | # is a contradiction between the two licences, the GPL |
||
| 13 | # takes preference. |
||
| 14 | # |
||
| 15 | # Foobar is distributed in the hope that it will be useful, |
||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 18 | # GNU General Public License for more details. |
||
| 19 | # |
||
| 20 | # You should have received a copy of the GNU General Public License |
||
| 21 | # along with Tsim Apiak. If not, see <http://www.gnu.org/licenses/>. |
||
| 46 | szabot | 22 | |
| 176 | muzer | 23 | |
| 46 | szabot | 24 | import tornado.database |
| 25 | import re |
||
| 26 | |||
| 27 | def getnavilist(): |
||
| 28 | ret = [] |
||
| 29 | current = u"" |
||
| 30 | db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
||
| 31 | for row in db.query(""" |
||
| 103 | szabot | 32 | SELECT * |
| 46 | szabot | 33 | FROM `metaWords` |
| 103 | szabot | 34 | WHERE partOfSpeech <> 'num.' AND partOfSpeech <> "prefix" |
| 35 | ORDER BY CHAR_LENGTH(navi) DESC"""): |
||
| 65 | szabot | 36 | if row["infixes"]: |
| 89 | szabot | 37 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]}) |
| 65 | szabot | 38 | else: |
| 89 | szabot | 39 | ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]}) |
| 46 | szabot | 40 | db.close() |
| 41 | return ret |
||
| 42 | |||
| 142 | szabot | 43 | def translate(wid,language): |
| 136 | muzer | 44 | db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
| 45 | for row in db.query(""" |
||
| 46 | SELECT * |
||
| 47 | FROM `localizedWords` |
||
| 145 | szabot | 48 | WHERE id = %s AND languageCode = %s""",wid,language): |
| 136 | muzer | 49 | ret = row["localized"] |
| 139 | szabot | 50 | break |
| 136 | muzer | 51 | db.close() |
| 176 | muzer | 52 | return ret |