X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=functions.py;h=f38a5c523a1420370140730e29c00f31cdad6b13;hp=862ea5f00cd5b932390eb5d34ed736703021572c;hb=bf6f3e6f469565e48fdc03216b1d95d72738e77a;hpb=b3bc705961fd8798f6379bad9e1d448a85f484a5 diff --git a/functions.py b/functions.py index 862ea5f..f38a5c5 100644 --- a/functions.py +++ b/functions.py @@ -35,7 +35,7 @@ def normpath_win32(path) : return path while '\\\\' in path : path = path.replace('\\\\', '\\') - if sys.platform == 'win32' and path.startswith('\\') and not path.startswith('\\\\') : + if path.startswith('\\') and not path.startswith('\\\\') : path = '\\' + path return path @@ -48,7 +48,9 @@ class TGen : def __getitem__(self, key): return self.tgen[key] - def read(self, path): + def read(self, path = None): + if path is None : + path = self.path with codecs.open(path, 'r', self.encoding) as f : tgen = f.read() tgen = [line.split('\t') for line in tgen.splitlines()] @@ -187,6 +189,19 @@ class History : def rmtab(self, analyse) : del self.opened[analyse['uuid']] + + def update(self, analyse) : + if 'matrix_name' in analyse : + self.matrixanalyse[analyse['uuid']].update(analyse) + elif 'corpus_name' in analyse : + self.corpus[analyse['uuid']].update(analyse) + elif 'corpus' in analyse : + self.analyses[analyse['uuid']].update(analyse) + else : + toupdate = [an for an in self.matrixanalyse[analyse['matrix']]['analyses'] if an['uuid'] == analyse['uuid']] + toupdate[0].update(analyse) + self.write() + self.read() def clean(self) : corpustodel = [corpus for corpus in self.history if not os.path.exists(corpus['ira'])] @@ -376,15 +391,8 @@ def treat_line_alceste(i, line) : return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]] def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()): - #print 'lecture des profils : ReadProfileAsDico' - #if Alceste : - # print 'lecture du dictionnaire de type' - # dictlem = {} - # for line in parent.corpus.lem_type_list : - # dictlem[line[0]] = line[1] dictlem = {} print 'lecture des profiles' - #encoding = sys.getdefaultencoding() FileReader = codecs.open(File, 'r', encoding) Filecontent = FileReader.readlines() FileReader.close() @@ -418,17 +426,17 @@ def GetTxtProfile(dictprofile, cluster_size) : return '\n\n'.join(proflist) def formatExceptionInfo(maxTBlevel=5): - cla, exc, trbk = sys.exc_info() - try : - excName = cla.__name__ - except : - excName = 'None' - try: - excArgs = exc.args[0] - except : - excArgs = "" - excTb = traceback.format_tb(trbk, maxTBlevel) - return (excName, excArgs, excTb) + cla, exc, trbk = sys.exc_info() + try : + excName = cla.__name__ + except : + excName = 'None' + try: + excArgs = exc.args[0] + except : + excArgs = "" + excTb = traceback.format_tb(trbk, maxTBlevel) + return (excName, excArgs, excTb) #fonction des etudiants de l'iut @@ -493,6 +501,7 @@ exceptions = {'paragrapheOT' : u"Un problème de formatage (présence d'un marqu 'EmptyText' : u"Texte vide (probablement un problème de formatage du corpus). Le problème est apparu à la ligne ", 'CorpusEncoding' : u"Problème d'encodage.", 'TextBeforeTextMark' : u"Problème de formatage : du texte avant le premier marqueur de texte (****). Le problème est survenu à la ligne ", + 'MissingAnalyse' : u'Aucun fichier à cet emplacement :\n', } def BugReport(parent, error = None): @@ -686,21 +695,21 @@ def read_list_file(filename, encoding = sys.getdefaultencoding()): def progressbar(self, maxi) : - if 'parent' in dir(self) : - parent = self.parent - else : - parent = self + ira = wx.GetApp().GetTopWindow() + parent = ira try : - print '###horrible hack progressbar' maxi = int(maxi) except : maxi = 1 - return wx.ProgressDialog("Traitements", + prog = wx.ProgressDialog("Traitements", "Veuillez patienter...", maximum=maxi, parent=parent, style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT ) + prog.SetIcon(ira._icon) + prog.SetSize((400,150)) + return prog def treat_var_mod(variables) :