Subversion Repositories navi

Rev

Rev 143 | Rev 145 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/python
# -*- coding: utf-8 -*-

import tornado.database
import re

def getnavilist():
    ret = []
    current = u""
    db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi")
    for row in db.query("""
    SELECT *
    FROM `metaWords`
    WHERE partOfSpeech <> 'num.' AND partOfSpeech <> "prefix"
    ORDER BY CHAR_LENGTH(navi) DESC"""
):
        if row["infixes"]:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]})
        else:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]})
    db.close()
    return ret

def translate(wid,language):
    db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi")
    for row in db.query("""
    SELECT *
    FROM `localizedWords`
    WHERE id = %s AND languageCode = %s"""
,(wid,language)):
        ret = row["localized"]
        break
    db.close()
    return ret