| 1 |
# |
|---|
| 2 |
# OpenDict |
|---|
| 3 |
# Copyright (c) 2005-2006 Martynas Jocius <mjoc@akl.lt> |
|---|
| 4 |
# |
|---|
| 5 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 6 |
# it under the terms of the GNU General Public License as published by |
|---|
| 7 |
# the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 |
# (at your opinion) any later version. |
|---|
| 9 |
# |
|---|
| 10 |
# This program is distributed in the hope that will be useful, |
|---|
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
# MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
# GNU General Public License for more detals. |
|---|
| 14 |
# |
|---|
| 15 |
# You shoud have received a copy of the GNU General Public License |
|---|
| 16 |
# along with this program; if not, write to the Free Software |
|---|
| 17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 18 |
# 02111-1307 USA |
|---|
| 19 |
# |
|---|
| 20 |
|
|---|
| 21 |
""" |
|---|
| 22 |
Metaclasses |
|---|
| 23 |
""" |
|---|
| 24 |
|
|---|
| 25 |
from lib import errortype |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
class SearchResult: |
|---|
| 29 |
"""Search result metaclass""" |
|---|
| 30 |
|
|---|
| 31 |
def __init__(self): |
|---|
| 32 |
"""Set default values""" |
|---|
| 33 |
|
|---|
| 34 |
self.error = errortype.OK |
|---|
| 35 |
self.translation = "" |
|---|
| 36 |
self.words = [] |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
def setError(self, err): |
|---|
| 40 |
"""Set error object""" |
|---|
| 41 |
|
|---|
| 42 |
self.error = err |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
def getError(self): |
|---|
| 46 |
"""Get error object""" |
|---|
| 47 |
|
|---|
| 48 |
return self.error |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
def setTranslation(self, trans): |
|---|
| 52 |
"""Set translation string""" |
|---|
| 53 |
|
|---|
| 54 |
self.translation = trans |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
def getTranslation(self): |
|---|
| 58 |
"""Get translation string""" |
|---|
| 59 |
|
|---|
| 60 |
return self.translation |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
def setWordList(self, words): |
|---|
| 64 |
"""Set word list""" |
|---|
| 65 |
|
|---|
| 66 |
self.words = words |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
def getWordList(self): |
|---|
| 70 |
"""Get word list""" |
|---|
| 71 |
|
|---|
| 72 |
return self.words |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
class Dictionary: |
|---|
| 77 |
"""Dictionary interface""" |
|---|
| 78 |
|
|---|
| 79 |
active = True |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
def start(self): |
|---|
| 83 |
"""Allocate resources""" |
|---|
| 84 |
|
|---|
| 85 |
pass |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
def stop(self): |
|---|
| 89 |
"""Free resources""" |
|---|
| 90 |
|
|---|
| 91 |
pass |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
def getType(self): |
|---|
| 95 |
"""Return dictionary type""" |
|---|
| 96 |
|
|---|
| 97 |
return None |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
def getName(self): |
|---|
| 101 |
"""Return plugin name""" |
|---|
| 102 |
|
|---|
| 103 |
return None |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
def getVersion(self): |
|---|
| 107 |
"""Return version""" |
|---|
| 108 |
|
|---|
| 109 |
return None |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
def getSize(self): |
|---|
| 113 |
"""Return size in kylobites""" |
|---|
| 114 |
|
|---|
| 115 |
return None |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
def getPath(self): |
|---|
| 119 |
"""Return ditionary path""" |
|---|
| 120 |
|
|---|
| 121 |
pass |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
def getAuthors(self): |
|---|
| 125 |
"""Return list of authors""" |
|---|
| 126 |
|
|---|
| 127 |
return None |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
def setEncoding(self, encoding): |
|---|
| 131 |
"""Set encoding""" |
|---|
| 132 |
|
|---|
| 133 |
pass |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
def getEncoding(self): |
|---|
| 137 |
"""Return encoding used by dictionary""" |
|---|
| 138 |
|
|---|
| 139 |
return None |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
def getUsesWordList(self): |
|---|
| 143 |
"""Return boolean value of word list usage""" |
|---|
| 144 |
|
|---|
| 145 |
return None |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
def getDescription(self): |
|---|
| 149 |
"""Returns description text""" |
|---|
| 150 |
|
|---|
| 151 |
return None |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
def getLicence(self): |
|---|
| 155 |
"""Return licence text""" |
|---|
| 156 |
|
|---|
| 157 |
return None |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
def getActive(self): |
|---|
| 161 |
return self.active |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
def setActive(self, active=True): |
|---|
| 165 |
self.active = active |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
def search(self, word): |
|---|
| 169 |
"""Lookup word""" |
|---|
| 170 |
|
|---|
| 171 |
return None |
|---|