1 | # -*- coding: latin-1 -*- |
---|
2 | import vbfunctions |
---|
3 | import sltgl |
---|
4 | import sltgen |
---|
5 | |
---|
6 | def OpConfigCargar_(): |
---|
7 | #Valores por defecto |
---|
8 | sltgl.optma = True |
---|
9 | sltgl.optdsem = True |
---|
10 | sltgl.optpades = True |
---|
11 | sltgl.optnpdes = False |
---|
12 | sltgl.optopconfig = True |
---|
13 | sltgl.optxi = True |
---|
14 | sltgl.optacc = False |
---|
15 | sltgl.optplu = False |
---|
16 | sltgl.optpart = False |
---|
17 | sltgl.optdemostra = True |
---|
18 | sltgl.optincoac = False |
---|
19 | sltgl.optpis = False |
---|
20 | sltgl.optpp = True |
---|
21 | sltgl.opttop = True |
---|
22 | #optAsi = False 'Así 1 (així) |
---|
23 | #optDesarrollar = False 'Desarrollar 1 (desenrotllar) |
---|
24 | #optHoy = False 'Hoy 1 (hui) |
---|
25 | #optOcho = True #Ocho 1 (huit) |
---|
26 | optQuinto = True #Quinto 1 (quint) |
---|
27 | #optServicio = True 'Servicio 1 (servei) |
---|
28 | #optTener = False 'Tener 1 (tindre) |
---|
29 | #optVer = False 'Ver 1 (vore) |
---|
30 | sltgl.optnoptimo = sltgl.optstandard |
---|
31 | sltgl.optnformal = sltgl.optconvergent |
---|
32 | sltgl.optnfcorrnodetectar = True |
---|
33 | sltgl.optnotradint = False |
---|
34 | |
---|
35 | |
---|
36 | def OpConfigCargar(): |
---|
37 | # |
---|
38 | # Cargar las opciones de configuración por defecto. |
---|
39 | # éstos valores por defecto, se pueden modificar en el fichero salt.ini |
---|
40 | # |
---|
41 | # VB2PY (UntranslatedCode) On Error Resume Next |
---|
42 | #Valores por defecto |
---|
43 | sltgl.optma = True |
---|
44 | sltgl.optdsem = True |
---|
45 | sltgl.optpades = True |
---|
46 | sltgl.optnpdes = False |
---|
47 | sltgl.optopconfig = True |
---|
48 | sltgl.optxi = True |
---|
49 | sltgl.optacc = False # Accents oberts o tancats en paraules tipus cafè (true) / café (false) |
---|
50 | sltgl.optplu = False # plurals: Ex. Textos (cas), si true es tradueix a texts i si false a textos. |
---|
51 | sltgl.optpart = False # participis |
---|
52 | sltgl.optdemostra = True # Demostratius |
---|
53 | sltgl.optincoac = False # Incoatius |
---|
54 | sltgl.optpis = False |
---|
55 | # El que fa es el pret. perfect simple, 'true' fa pret. perfet perifr. |
---|
56 | sltgl.optpp = False |
---|
57 | sltgl.opttop = True |
---|
58 | sltgl.optnoptimo = sltgl.optstandard |
---|
59 | sltgl.optnformal = sltgl.optformal |
---|
60 | sltgl.optnfcorrnodetectar = True |
---|
61 | sltgl.optnotradint = False |
---|
62 | #Modificar según fichero de configuración |
---|
63 | f=file(sltgl.cfgPath+'/sltsrv.config','rb') |
---|
64 | scfg=f.read() |
---|
65 | f.close() |
---|
66 | cfg=eval(scfg) |
---|
67 | #import ConfigParser |
---|
68 | #cfg=ConfigParser.ConfigParser() |
---|
69 | #cfg.read(os.path.abspath(sltgl.cfgPath+'/sltsrv.config')) |
---|
70 | sltgl.optma=GetConfig(cfg,'config','maj',vTrue='2') |
---|
71 | #sltgl.optdsem=GetConfig(cfg,'config','dsem',vTrue='2') |
---|
72 | sltgl.optdsem=1 |
---|
73 | sltgl.optpades=GetConfig(cfg,'config','pades',vTrue='2') |
---|
74 | sltgl.optnpdes=GetConfig(cfg,'config','npdes',vTrue='2') |
---|
75 | sltgl.optopconfig=GetConfig(cfg,'config','opconfig',vTrue='2') |
---|
76 | #sltgl.optxi=GetConfig(cfg,'config','xifres',vTrue='2') |
---|
77 | sltgl.optxi=True |
---|
78 | sltgl.optplu=GetConfig(cfg,'config','plural',vTrue='2') |
---|
79 | #sltgl.optdemostra=GetConfig(cfg,'config','demostratius',vTrue='1') |
---|
80 | # Aquest |
---|
81 | sltgl.optdemostra=False |
---|
82 | # eix /ejes /eje /ese |
---|
83 | #sltgl.optincoac=GetConfig(cfg,'config','incoatius',vTrue='1') |
---|
84 | sltgl.optincoac=False |
---|
85 | sltgl.optacc=GetConfig(cfg,'config','acc',vTrue='2') |
---|
86 | sltgl.opttop=GetConfig(cfg,'config','top',vTrue='1') |
---|
87 | #sltgl.optnoptimo=GetConfig(cfg,'config','noptimo',vDef=sltgl.optnoptimo) |
---|
88 | sltgl.optnoptimo=sltgl.optstandard |
---|
89 | sltgl.optnformal=GetConfig(cfg,'config','nformal',vDef=sltgl.optnformal) |
---|
90 | sltgl.optnfcorrnodetectar=GetConfig(cfg,'config','nfcorr',vTrue='2') |
---|
91 | sltgl.exereglesdesact=GetConfig(cfg,'config','ExeReglesDesact',vTrue='SI') |
---|
92 | sltgl.optnfcorrnodetectar=GetConfig(cfg,'config','nfcorr',vTrue='2') |
---|
93 | #Lèxic, per assimilació a altres opcions de morfosintaxi TODO |
---|
94 | sltgl.optasi=GetConfig(cfg,'config','así',vFalse='1') |
---|
95 | #Desarrollar |
---|
96 | sltgl.optdesarrollar=2 #GetConfig(cfg,'config','desarrollar',vTrue='2') |
---|
97 | #sltgl.optdesarrollar=False |
---|
98 | sltgl.opthoy=GetConfig(cfg,'config','hoy',vFalse='1') |
---|
99 | sltgl.optocho = sltgl.optacc |
---|
100 | sltgl.opthoy = sltgl.optacc |
---|
101 | # Tindre / Tenir |
---|
102 | sltgl.opttener = sltgl.optacc |
---|
103 | |
---|
104 | # Cinqué / Quinto |
---|
105 | sltgl.optquinto = not sltgl.optdemostra |
---|
106 | # Servei / Servici |
---|
107 | sltgl.optservicio =True |
---|
108 | sltgl.optver=GetConfig(cfg,'config','ver',vFalse='1') |
---|
109 | |
---|
110 | sltgl.void_npalmin=GetConfig(cfg,'config','void_npalmin',vDef=9999) |
---|
111 | sltgl.void_percent=GetConfig(cfg,'config','void_percent',vDef=100) |
---|
112 | |
---|
113 | def OpConfigGuardar(): |
---|
114 | # |
---|
115 | # Guardar las opciones de configuración en salt.ini |
---|
116 | # |
---|
117 | # VB2PY (UntranslatedCode) On Error Resume Next |
---|
118 | #Modificar según salt.ini |
---|
119 | cadena = vbfunctions.IIf(sltgl.optma == True, '2', '1') |
---|
120 | WriteBDConfig('maj', cadena) |
---|
121 | cadena = vbfunctions.IIf(sltgl.optdsem == True, '2', '1') |
---|
122 | WriteBDConfig('dsem', cadena) |
---|
123 | cadena = vbfunctions.IIf(sltgl.optpades == True, '2', '1') |
---|
124 | WriteBDConfig('pades', cadena) |
---|
125 | cadena = vbfunctions.IIf(sltgl.optnpdes == True, '2', '1') |
---|
126 | WriteBDConfig('npdes', cadena) |
---|
127 | cadena = vbfunctions.IIf(sltgl.optopconfig == True, '2', '1') |
---|
128 | WriteBDConfig('opconfig', cadena) |
---|
129 | cadena = vbfunctions.IIf(sltgl.optxi == True, '2', '1') |
---|
130 | WriteBDConfig('xifres', cadena) |
---|
131 | cadena = vbfunctions.IIf(sltgl.optplu == True, '2', '1') |
---|
132 | WriteBDConfig('plural', cadena) |
---|
133 | cadena = vbfunctions.IIf(sltgl.optdemostra == False, '2', '1') |
---|
134 | WriteBDConfig('demostratius', cadena) |
---|
135 | cadena = vbfunctions.IIf(sltgl.optincoac == False, '2', '1') |
---|
136 | WriteBDConfig('incoatius', cadena) |
---|
137 | cadena = vbfunctions.IIf(sltgl.optacc == True, '2', '1') |
---|
138 | WriteBDConfig('acc', cadena) |
---|
139 | cadena = vbfunctions.IIf(sltgl.opttop == False, '2', '1') |
---|
140 | WriteBDConfig('top', cadena) |
---|
141 | cadena = vbfunctions.IIf(sltgl.opttener == True, '2', '1') |
---|
142 | WriteBDConfig('tener', cadena) |
---|
143 | cadena = Trim(str(sltgl.optnoptimo)) |
---|
144 | WriteBDConfig('noptimo', cadena) |
---|
145 | cadena = Trim(str(sltgl.optnformal)) |
---|
146 | WriteBDConfig('nformal', cadena) |
---|
147 | cadena = vbfunctions.IIf(sltgl.optnfcorrnodetectar == True, '2', '1') |
---|
148 | WriteBDConfig('nfcorr', cadena) |
---|
149 | |
---|
150 | def ConfigLoad(): |
---|
151 | #Obtener el contenido del fichero de configuración |
---|
152 | #Retorno: Contenido del fichero de configuración |
---|
153 | f=file(sltgl.cfgPath+'/sltsrv.config','rb') |
---|
154 | scfg=f.read() |
---|
155 | f.close() |
---|
156 | return scfg |
---|
157 | |
---|
158 | def ConfigSave(scfg): |
---|
159 | #Guardar nueva configuración en el fichero de configuración |
---|
160 | #Entrada: scfg: Nueva configuración (como string) |
---|
161 | f=file(sltgl.cfgPath+'/sltsrv.config','wb') |
---|
162 | f.write(scfg) |
---|
163 | f.close() |
---|
164 | |
---|
165 | def Credits(): |
---|
166 | txt=[u'Direcció Salt 4',[u'Vicent Satorres'],u'Direcció Salt 3',[u'Josep Lacreu',u'Vicent Satorres'], |
---|
167 | u'Direcció Salt 1 i 2',[u'Josep Lacreu'],u'Coordinació lingüística versions 1, 2 i 3', |
---|
168 | [u'Conxa Chulià',u'Robert Escolano'],u'Procés informàtic',[u'Rafael Pinter'], |
---|
169 | u'Suport informàtic versions Linux',[u'Javier García', u'Ángel Berlanas'], |
---|
170 | u'Procés lingüístic Salt 3 i 4',[u'Ferran Bataller', u'Maluy Benet', u'Cristina Domingo', |
---|
171 | u'Josep G. Illa', u'Enric M. Català', u'Lluís Julián', u'Aurora Navarro', |
---|
172 | u'Juli Ortells', u'Anna Eva Peig', u'Donís Seguí', u'Josep Sendra', |
---|
173 | u'Santiago Vallés'], |
---|
174 | u'Procés lingüístic Salt 1 i 2',[u'Ernest Anyó',u'Pepa Baixauli',u'Cristina Domingo', |
---|
175 | u'Josep G. Illa',u'Mari Trini Garcia',u'Sílvia Garcia',u'Enric M. Català', |
---|
176 | u'Núria Martínez',u'Rafel Moreno',u'Aurora Navarro',u'Juli Ortells', |
---|
177 | u'Susanna Pardines',u'Àngels Romero',u'Vicenta Sabater',u'Marina Sahuquillo', |
---|
178 | u'Beatriu Sales',u'Isabel Saval',u'Donís Seguí',u'Empar Sòria'], |
---|
179 | u'Diccionari bilingüe Salt 4',[u'Robert Escolano',u'Toni Lluch',u'Xavier Casero'], |
---|
180 | u'Diccionari Salt 4',[u'Ofèlia Sanmartín'], |
---|
181 | u'Grafisme Salt 4',[u'ädisseny (Sònia i Àlex Aygües)']] |
---|
182 | return txt |
---|
183 | |
---|
184 | def VerModalidad_(): |
---|
185 | sltgl.tbvbmodval = 'vbmodval' |
---|
186 | sltgl.tbpron = 'pron' |
---|
187 | sltgl.tbpronerr = 'pronerr' |
---|
188 | sltgl.tbpadubt = vbfunctions.IIf(sltgl.optincoac, 'padubt', 'padubtaquest') |
---|
189 | sltgl.tbvbdubt = 'vbdubt' |
---|
190 | sltgl.tbfrfetes = 'frfetes' |
---|
191 | sltgl.tbdoblsem = 'metadoblsem' |
---|
192 | sltgl.tbajuda = 'ajuda' |
---|
193 | sltgl.tbajudacont = 'AjudaCont' |
---|
194 | |
---|
195 | def VerConfig(): |
---|
196 | _ret = None |
---|
197 | # |
---|
198 | # Analizar si se permite entrar en configuración, |
---|
199 | # según el fichero INI |
---|
200 | # |
---|
201 | # Retorno: True, si se permite |
---|
202 | # False, si no se permite |
---|
203 | # |
---|
204 | _ret = True |
---|
205 | ret,cadena = GetBDConfig('àmbit', cadena) |
---|
206 | if ret > 0: |
---|
207 | if vbfunctions.Left(cadena, ret) == '2': |
---|
208 | _ret = False |
---|
209 | return _ret |
---|
210 | |
---|
211 | def IdiomaMsg(msgId): |
---|
212 | _ret = None |
---|
213 | # |
---|
214 | # Obtener un mensaje de aviso, según el idioma seleccionado |
---|
215 | # (pppIdAvisos) |
---|
216 | # |
---|
217 | # Entrada: msgId: Identificador de mensaje |
---|
218 | # |
---|
219 | # Retorno: Mensaje correspondiente a msgId y pppIdAvisos |
---|
220 | # |
---|
221 | _select367 = msgId |
---|
222 | if (_select367 == sltgl.msggen): |
---|
223 | _ret = sltgl.msggenval |
---|
224 | elif (_select367 == sltgl.msggenyaenexe): |
---|
225 | _ret = sltgl.msggenyaenexeval |
---|
226 | elif (_select367 == sltgl.msggennobd): |
---|
227 | _ret = sltgl.msggennobdval |
---|
228 | elif (_select367 == sltgl.msgfierr): |
---|
229 | _ret = sltgl.msgfierrval |
---|
230 | elif (_select367 == sltgl.msgfinoopen): |
---|
231 | _ret = sltgl.msgfinoopenval |
---|
232 | elif (_select367 == sltgl.msgfinoopen2): |
---|
233 | _ret = sltgl.msgfinoopen2val |
---|
234 | elif (_select367 == sltgl.msgfinoguarda): |
---|
235 | _ret = sltgl.msgfinoguardaval |
---|
236 | elif (_select367 == sltgl.msgfinocarga): |
---|
237 | _ret = sltgl.msgfinocargaval |
---|
238 | elif (_select367 == sltgl.msgfinoimpo): |
---|
239 | _ret = sltgl.msgfinoimpoval |
---|
240 | elif (_select367 == sltgl.msgfigran): |
---|
241 | _ret = sltgl.msgfigranval |
---|
242 | elif (_select367 == sltgl.msgimanoinsert): |
---|
243 | _ret = sltgl.msgimanoinsertval |
---|
244 | elif (_select367 == sltgl.msgimabordererr): |
---|
245 | _ret = sltgl.msgimabordererrval |
---|
246 | elif (_select367 == sltgl.msgtraerr): |
---|
247 | _ret = sltgl.msgtraerrval |
---|
248 | elif (_select367 == sltgl.msgtrafin): |
---|
249 | _ret = sltgl.msgtrafinval |
---|
250 | elif (_select367 == sltgl.msgtraMarca): |
---|
251 | _ret = sltgl.msgtramarcaval |
---|
252 | elif (_select367 == sltgl.msgcorrfin): |
---|
253 | _ret = sltgl.msgcorrfinval |
---|
254 | elif (_select367 == sltgl.msgrevfin): |
---|
255 | _ret = sltgl.msgrevfinval |
---|
256 | elif (_select367 == sltgl.msgrevcan): |
---|
257 | _ret = sltgl.msgrevcanval |
---|
258 | elif (_select367 == sltgl.msgrevpte): |
---|
259 | _ret = sltgl.msgrevpteval |
---|
260 | elif (_select367 == sltgl.msgajunoexis): |
---|
261 | _ret = sltgl.msgajunoexisval |
---|
262 | elif (_select367 == sltgl.msgadminnoopen): |
---|
263 | _ret = sltgl.msgadminnoopenval |
---|
264 | elif (_select367 == sltgl.msgadminerrafe): |
---|
265 | _ret = sltgl.msgadminerrafeval |
---|
266 | elif (_select367 == sltgl.msgbusreemfin): |
---|
267 | _ret = sltgl.msgbusreemfinval |
---|
268 | elif (_select367 == sltgl.msgbusreemtit): |
---|
269 | _ret = sltgl.msgbusreemtitval |
---|
270 | elif (_select367 == sltgl.msgfiguardar1): |
---|
271 | _ret = sltgl.msgfiguardar1val |
---|
272 | elif (_select367 == sltgl.msgfiguardar2): |
---|
273 | _ret = sltgl.msgfiguardar2val |
---|
274 | elif (_select367 == sltgl.msgfiguardar3): |
---|
275 | _ret = sltgl.msgfiguardar3val |
---|
276 | elif (_select367 == sltgl.msgimarutaerr): |
---|
277 | _ret = sltgl.msgimarutaerrval |
---|
278 | return _ret |
---|
279 | |
---|
280 | def Main(): |
---|
281 | frmDOC.Show() |
---|
282 | |
---|
283 | def GetConfig(cfg,sec,clave,vDef=None,vTrue=None,vFalse=None): |
---|
284 | _ret = vDef |
---|
285 | # |
---|
286 | # Obtener información del fichero de configuración |
---|
287 | # |
---|
288 | # Entrada: cfg: Objeto asociado al fichero de configuración |
---|
289 | # sec: Sección |
---|
290 | # clave: Clave de la entrada |
---|
291 | # vDef: Valor por defecto |
---|
292 | # vTrue: Valor para respoder True |
---|
293 | # vFalse: Valor para responder False |
---|
294 | # |
---|
295 | # Retorno: Por defecto retorna vDef. Si existe retorna valor o True/False si valor == vTrue/vFalse |
---|
296 | # |
---|
297 | #if cfg.has_option(sec,clave): |
---|
298 | #if vTrue!=None: |
---|
299 | #_ret = vbfunctions.IIf(vbfunctions.LCase(cfg.get(sec,clave)) == vbfunctions.LCase(vTrue), True, False) |
---|
300 | #elif vFalse!=None: |
---|
301 | #_ret = vbfunctions.IIf(vbfunctions.LCase(cfg.get(sec,clave)) == vbfunctions.LCase(vFalse), False, True) |
---|
302 | #else: |
---|
303 | #_ret=cfg.get(sec,clave) |
---|
304 | #if vDef!=None: |
---|
305 | #if str(type(vDef))=="<type 'int'>": |
---|
306 | #_ret=eval(_ret) |
---|
307 | if cfg.has_key(sec): |
---|
308 | if cfg[sec].has_key(clave): |
---|
309 | if vTrue!=None: |
---|
310 | _ret = vbfunctions.IIf(vbfunctions.LCase(str(cfg[sec][clave])) == vbfunctions.LCase(vTrue), True, False) |
---|
311 | elif vFalse!=None: |
---|
312 | _ret = vbfunctions.IIf(vbfunctions.LCase(str(cfg[sec][clave])) == vbfunctions.LCase(vFalse), False, True) |
---|
313 | else: |
---|
314 | _ret=cfg[sec][clave] |
---|
315 | return _ret |
---|
316 | |
---|
317 | def WriteBDConfig(Clau, Valor): |
---|
318 | # |
---|
319 | # Guardar información de la tabla Config de la base de datos |
---|
320 | # |
---|
321 | # Entrada: Clau: Clave a buscar |
---|
322 | # Valor: Información asociada a Clau |
---|
323 | # |
---|
324 | r=RSet() |
---|
325 | sql = 'select * from Config where Clau = %s' #+ Clau + '"' |
---|
326 | r.OpenR(sql, (Clau,)) # TODO |
---|
327 | if r.eof: |
---|
328 | sql = 'insert into Config (Clau,Valor) values ("' + Clau + '","' + Valor + '")' |
---|
329 | else: |
---|
330 | sql = 'update Config set Valor = "' + Valor + '" where Clau = "' + Clau + '"' |
---|
331 | sltgl.curd.execute(sql,()) |
---|
332 | |
---|
333 | # VB2PY (UntranslatedCode) Attribute VB_Name = "sltslt" |
---|
334 | # VB2PY (UntranslatedCode) Option Explicit |
---|