root/tags/release-0.6.2/lib/dicttype.py

Revision 1, 2.6 kB (checked in by mjoc, 2 years ago)

Initial import.

Line 
1 #
2 # OpenDict
3 # Copyright (c) 2005 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 Dictionary types
23 """
24
25 from lib import newplugin
26
27
28 class DictionaryType:
29     """Dictionary type interface"""
30
31     dictClass = None
32     fileExtentions = None
33     name = None
34     shortIdName = None
35  
36
37     def getClass(self):
38         """Return dictionary class"""
39
40         return self.dictClass
41    
42
43     def getFileExtentions(self):
44         """Return file extention"""
45
46         return self.fileExtentions
47
48
49     def getName(self):
50         """Return type name"""
51
52         return self.name
53
54
55     def getIdName(self):
56         """Return short ID name"""
57
58         return self.shortIdName
59
60
61 class TypePlugin(DictionaryType):
62     """Dictionary plugin"""
63
64     dictClass = newplugin.DictionaryPlugin
65     fileExtentions = ('zip',)
66     name = "OpenDict dictionary plugin"
67
68
69
70 class TypeSlowo(DictionaryType):
71     """Slowo dictionary format"""
72
73     import parser
74
75     dictClass = parser.SlowoParser
76     fileExtentions = ('dwa',)
77     name = "Slowo dictionary"
78     shortIdName = "slowo"
79
80
81
82 class TypeMova(DictionaryType):
83     """Mova dictionary format"""
84
85     import parser
86
87     dictClass = parser.MovaParser
88     fileExtentions = ('mova',)
89     name = "Mova dictionary"
90     shortIdName = "mova"
91
92    
93
94 class TypeTMX(DictionaryType):
95     """TMX dictionary format"""
96
97     import parser
98
99     dictClass = parser.TMXParser
100     fileExtentions = ('tmx',)
101     name = "TMX dictionary"
102     shortIdName = "tmx"
103
104
105
106 class TypeDict(DictionaryType):
107     """DICT dictionary type"""
108
109     import parser
110
111     dictClass = parser.DictParser
112     fileExtentions = ('dict', 'dz',)
113     name = "DICT dictionary"
114     shortIdName = "dict"
115
116
117
118 # Constant instances
119 PLUGIN = TypePlugin()
120 SLOWO = TypeSlowo()
121 MOVA = TypeMova()
122 #TMX = TypeTMX()
123 DICT = TypeDict()
124
125 # Supported types tuple
126 supportedTypes = (PLUGIN, SLOWO, MOVA, DICT)
127
128 # Plain dictionary types (data file)
129 plainTypes = (SLOWO, MOVA, DICT)
130
131 # Types for which index table is made
132 indexableTypes = (SLOWO, MOVA)
Note: See TracBrowser for help on using the browser.