X-Git-Url: http://www.iramuteq.org/git?a=blobdiff_plain;f=tabsimi.py;h=e8220373fac6f42edd09dbc6ad7d71b23bdc7f00;hb=refs%2Fheads%2F3.0;hp=8b7c07005274a0c584213840fbdbdcfbce09f9ad;hpb=238d461ff111b1bc3302494de4d9b630f9e9f623;p=iramuteq diff --git a/tabsimi.py b/tabsimi.py index 8b7c070..e822037 100644 --- a/tabsimi.py +++ b/tabsimi.py @@ -1,27 +1,42 @@ -#!/bin/env python # -*- coding: utf-8 -*- #Author: Pierre Ratinaud -#Copyright (c) 2009-2010 Pierre Ratinaud +#Copyright (c) 2008-2020 Pierre Ratinaud +#modification pour python 3 : Laurent Mérat, 6x7 - mai 2020 #License: GNU/GPL +#------------------------------------ +# import des modules python +#------------------------------------ +import os +import tempfile +import datetime +from time import sleep +from uuid import uuid4 + +import langue +langue.run() + +#------------------------------------ +# import des modules wx +#------------------------------------ +import wx + +#------------------------------------ +# import des fichiers du projet +#------------------------------------ from chemins import ConstructPathOut, simipath, ffr, PathOut -from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod +from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod, normpath_win32 from dialog import SelectColDial, FreqDialog from guifunct import PrefSimi from analysematrix import AnalyseMatrix from PrintRScript import PrintSimiScript from listlex import * -import wx -import os -import tempfile -import datetime -from ConfigParser import RawConfigParser -from time import sleep -from uuid import uuid4 +from configparser import RawConfigParser class DoSimi(AnalyseMatrix): - def doanalyse(self) : + + def doparametres(self, dlg = None) : self.fromprof = self.parametres.get('fromprof', False) self.wordgraph = self.parametres.get('wordgraph', False) self.listactives = self.parametres.get('listactives', False) @@ -29,18 +44,8 @@ class DoSimi(AnalyseMatrix): self.openfromprof = self.parametres.get('openfromprof', False) self.cmd = self.parametres.get('cmd', False) self.dirout = self.parametres.get('pathout', False) - #parent, matrix = None, parametres = None, isopen = False, fromprof = False, pathout = False, filename ='', gparent = False, wordgraph = False, listactives = False, actives = False, cmd = False, openfromprof=False, tableau = None): -#------------------------------------------------------------------- - # self.fromprof = fromprof - # self.wordgraph = wordgraph - # self.listactives = listactives - # self.actives = actives - # self.openfromprof = openfromprof - # self.cmd = cmd - # self.dirout = pathout - # if parametres is not None and fromprof: if self.fromprof: - self.paramsimi = parametres + self.paramsimi = self.parametres else : self.paramsimi = {'coeff' : 0, 'layout' : 2, @@ -76,32 +81,22 @@ class DoSimi(AnalyseMatrix): 'communities' : 0, } self.indices = indices_simi - #if fromprof : - # self.parent = parent.parent - # self.Source = parent - #else : self.Source = None if self.dirout : self.pathout = PathOut(dirout = self.dirout) - - #self.RPath = self.parent.PathPath.get('PATHS', 'rpath') if not self.parametres.get('isopen', False) : - #if not fromprof : - # self.tableau = self.parent.tableau - #else : - # self.tableau = parent.tableau if self.tableau is None : self.tableau = parent.tableau self.tableau.parametres['mineff'] = 0 if not self.fromprof : - dialcol = FreqDialog(self.parent, self.tableau.get_colnames(), _(u"Select columns").decode('utf8'), size=(600, 250), showNA = False) - dialcol.CenterOnParent() + dialcol = FreqDialog(self.parent, self.tableau.get_colnames(), _("Select columns"), size=(600, 250), showNA = False) + dialcol.CenterOnParent() res = dialcol.ShowModal() else : res = wx.ID_OK if res == wx.ID_OK : if not self.actives : - self.tableau.selected_col = dialcol.list_box_1.GetSelections() + self.tableau.selected_col = dialcol.m_listBox1.GetSelections() actives = self.tableau.getactlistfromselection(self.tableau.selected_col) else : actives = self.actives @@ -126,24 +121,14 @@ class DoSimi(AnalyseMatrix): self.paramsimi = self.make_param() self.parametres.update(self.paramsimi) #self.parametres['type'] = 'simimatrix' - if not self.pathout : + if not self.pathout : self.parametres['pathout'] = ConstructPathOut(self.parametres['pathout'], 'SimiMatrix') - print self.parametres['pathout'] else : self.parametres['pathout'] = self.dirout self.pathout.createdir(self.parametres['pathout']) self.pathout.dirout = self.parametres['pathout'] - #self.parametres['filename'] = self.tableau.parametres['filename'] self.dial.Destroy() - self.doanalyse2() - #dlg = wx.ProgressDialog("Traitements", - # "Veuillez patienter...", - # maximum=4, - # parent=self.parent, - # style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME - # ) - #dlg.Center() - #AnalyseMatrix.__init__(self, parent, self.tableau, self.paramsimi, dlg = dlg) + #self.doanalyse2() else : self.dial.Destroy() self.parametres = None @@ -153,24 +138,23 @@ class DoSimi(AnalyseMatrix): self.parametres = None return False - def doanalyse2(self) : + def doanalyse(self) : self.pathout.basefiles(simipath) - with open(self.pathout['selected.csv'], 'w') as f : - f.write('\n'.join([`val` for val in self.column])) - + with open(normpath_win32(self.pathout['selected.csv']), 'w', encoding='utf8') as f : + f.write('\n'.join([repr(val) for val in self.column])) count = 1 keepGoing = self.dlg.Update(count) - #---------------------------------------------------------------- + #---------------------------------------------------------------- self.DictForme = {} self.Min = 10 self.Linecontent = [] - #-------------------------------------------------------- + #-------------------------------------------------------- count += 1 #if not self.fromprof : #self.pathout = ConstructPathOut(self.tableau.parametres['filename'], 'Simi') #self.DictPathOut = construct_simipath(self.pathout) self.tableau.dictpathout = self.pathout - self.dlg.Update(count, u"passage en O/1") + self.dlg.Update(count, "passage en O/1") if not self.fromprof : self.tableau.make_01_from_selection(self.tableau.selected_col) #self.Linecontent = parent.table @@ -184,15 +168,15 @@ class DoSimi(AnalyseMatrix): self.script.make_script() #self.PrintScript() count += 1 - self.dlg.Update(count, u"R...") + self.dlg.Update(count, "R...") #self.DoR(script.scriptout, dlg = self.dlg, message = 'R...') self.tmpfile = self.script.scriptout self.DoR(self.dlg) self.addgraph() - self.tableau.save_tableau(self.pathout['db']) + self.tableau.save_tableau(self.pathout['analyse.db']) #self.make_ira() - count += 1 - self.dlg.Update(count, u"") + #count += 1 + #self.dlg.Update(count, u"") self.dlg.Destroy() #self.dial.Destroy() #self.dolayout() @@ -200,7 +184,6 @@ class DoSimi(AnalyseMatrix): fromprof = True else: fromprof = False - def make_param(self) : if self.paramsimi['first'] : @@ -208,7 +191,6 @@ class DoSimi(AnalyseMatrix): else : keep_coord = self.dial.check_coord.GetValue() #self.select = self.dial.check_colch.GetValue() - paramsimi = {'coeff' : self.dial.choice1.GetSelection(), 'layout' : self.dial.choice2.GetSelection(), 'type_graph' : self.dial.choice3.GetSelection(), @@ -254,8 +236,7 @@ class DoSimi(AnalyseMatrix): if 'tmpchi' in self.paramsimi : paramsimi['tmpchi'] = self.paramsimi['tmpchi'] return paramsimi - -# + def addgraph(self) : if self.parametres['type_graph'] == 1: if self.parametres['svg'] : @@ -269,7 +250,7 @@ class DoSimi(AnalyseMatrix): else : graph_simi = [[os.path.basename(fileout), self.script.txtgraph]] print_liste(self.DictPathOut['liste_graph'], graph_simi) - + def DoR(self, dlg): if self.paramsimi['type_graph'] == 1 : graph = False @@ -281,10 +262,8 @@ class DoSimi(AnalyseMatrix): if self.paramsimi['type_graph'] == 1 : while pid.poll() == None : if not self.cmd : - dlg.Pulse(u'R ...') + dlg.Pulse('R ...') sleep(0.2) else : sleep(0.2) check_Rresult(self.parent, pid) - -