else:
opener ="open" if sys.platform == "darwin" else "xdg-open"
#call([opener, folder])
- call(["%s %s &" % (opener, folder)], shell=True)
+ call(["%s '%s' &" % (opener, folder)], shell=True)
def normpath_win32(path) :
if not sys.platform == 'win32' :
self.read()
def read(self) :
- d = shelve.open(self.filein)
+ with open(self.filein, 'r') as fjson :
+ d = json.load(fjson)
+# d = shelve.open(self.filein, protocol=1)
self.history = d.get('history', [])
self.matrix = d.get('matrix', [])
self.ordercorpus = dict([[corpus['uuid'], i] for i, corpus in enumerate(self.history)])
self.analyses = dict([[analyse['uuid'], analyse] for corpus in self.history for analyse in corpus.get('analyses', [])])
self.matrixanalyse = dict([[mat['uuid'], mat] for mat in self.matrix])
self.ordermatrix = dict([[matrix['uuid'], i] for i, matrix in enumerate(self.matrix)])
- d.close()
+# d.close()
def write(self) :
- d = shelve.open(self.filein)
+ d = {}
d['history'] = self.history
d['matrix'] = self.matrix
- d.close()
+ with open(self.filein, 'w') as f :
+ f.write(json.dumps(d, indent=4, default=str))
+ #d = shelve.open(self.filein, protocol=1)
+ #d.close()
def add(self, analyse) :
log.info('add to history %s' % analyse.get('corpus_name', 'pas un corpus'))
# var_mod[var].append(variable)
return var_mod
-def doconcorde(corpus, uces, mots, uci = False) :
+def doconcorde(corpus, uces, mots, uci = False, fontsize=16) :
if not uci :
ucestxt1 = [row for row in corpus.getconcorde(uces)]
else :
listmot = [corpus.getforme(fid).forme for lem in listmot for fid in lem]
mothtml = ['<font color=red><b>%s</b></font>' % mot for mot in listmot]
dmots = dict(list(zip(listmot, mothtml)))
+ presfont = '<p><b><font size="%i">' % fontsize
+ font = '<font size="%i">' % fontsize
for uce in uces :
ucetxt = ucestxt1[uce].split()
ucetxt = ' '.join([dmots.get(mot, mot) for mot in ucetxt])
if not uci :
uciid = corpus.getucefromid(uce).uci
- ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[corpus.getucefromid(uce).uci].etoiles) + '<a href="%i_%i"> *%i_%i</a></b></p>' % (uciid, uce, uciid, uce))
+ ucis_txt.append(presfont + ' '.join(corpus.ucis[corpus.getucefromid(uce).uci].etoiles) + '<a href="%i_%i"> *%i_%i</a></font></b></p>' % (uciid, uce, uciid, uce))
else :
- ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[uce].etoiles) + '</b></p>')
- ucestxt.append(ucetxt)
+ ucis_txt.append(presfont + ' '.join(corpus.ucis[uce].etoiles) + '</font></b></p>')
+ ucestxt.append(font + ucetxt + '</font>')
return ucis_txt, ucestxt