X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=layout.py;h=bdaa0384049da0427a05d33069f5633ebc235495;hb=c93664303b811f5e664dfe85dd6cb7de99a5b557;hp=2f8d985c87ac2ccb761e22d62f9dadafa678920b;hpb=eaa044d1147e26b82942ce56d5965c83fdddf069;p=iramuteq diff --git a/layout.py b/layout.py index 2f8d985..bdaa038 100644 --- a/layout.py +++ b/layout.py @@ -419,7 +419,7 @@ class OpenCHDS(): for i in range(0, clnb) : clusternames[i] = ' '.join(['%i' % (i + 1), _('Cluster'), '%i' % (i + 1)]) if os.path.exists(self.pathout['classes_names.txt']) : - with codecs.open(self.pathout['classes_names.txt'], 'r', self.parent.syscoding) as f : + with open(self.pathout['classes_names.txt'], 'r', encoding='utf8') as f : clusternames_ = f.read() clusternames_ = dict([[i, ' '.join([repr(i + 1), line])] for i, line in enumerate(clusternames_.splitlines())]) clusternames.update(clusternames_) @@ -430,7 +430,7 @@ class OpenCHDS(): panel = wx.Panel(parent, -1) sizer1 = wx.BoxSizer(wx.VERTICAL) if os.path.exists(DictPathOut['pre_rapport']): - with codecs.open(DictPathOut['pre_rapport'], 'r') as f : + with open(DictPathOut['pre_rapport'], 'r', encoding='utf8') as f : txt = f.read() self.debtext = txt else : @@ -543,7 +543,7 @@ class OpenCHDS(): self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenchi2.csv') TgenLayout(panel) if os.path.exists(self.dictpathout['translations.txt']) : - with codecs.open(self.dictpathout['translations.txt'], 'r', 'utf8') as f: + with open(self.dictpathout['translations.txt'], 'r', encoding='utf8') as f: translist = f.read() translist = [line.split('\t') for line in translist.splitlines()] for line in translist : @@ -562,7 +562,7 @@ class OpenCHDS(): def opentrans(self, trans) : prof = ReadProfileAsDico(self.dictpathout[trans[0]], False) - with codecs.open(self.dictpathout[trans[1]], 'r') as f : + with open(self.dictpathout[trans[1]], 'r', encoding='utf8') as f : lems = f.read() lems = [line.split('\t') for line in lems.splitlines()] lems = dict(lems) @@ -633,7 +633,7 @@ def PrintRapport(self, corpus, parametres, istxt = True): txt += ''.join([sep, '###########################', sep, _('time'), ' : %s' % parametres.get('time', ''), sep, '###########################', sep]) # ecriture du resultat dans le fichier - with open(self.pathout['pre_rapport'], 'w') as f : + with open(self.pathout['pre_rapport'], 'w', encoding='utf8') as f : f.write(txt) @@ -693,7 +693,7 @@ class TgenLayout : ira = wx.GetApp().GetTopWindow() tgenpath = os.path.join(parametres['pathout'], 'tgen.csv') self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t") - tgen = TGen(path = tgenpath, encoding = parametres['encoding']) + tgen = TGen(path = tgenpath, encoding = 'UTF-8') tgen.read() tgenlempath = os.path.join(parametres['pathout'], 'tgenlemchi2.csv') if os.path.exists(tgenlempath) : @@ -735,6 +735,7 @@ class dolexlayout : self.dictpathout = StatTxtPathOut(parametres['pathout']) #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db']) self.parent = ira + self.corpus.parametres['syscoding'] = 'UTF8' self.encoding = self.corpus.parametres['syscoding'] self.parametres = parametres self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding']) @@ -823,10 +824,10 @@ class StatLayout: lcle = {'total' :'total.csv', 'formes_actives':'formes_actives.csv', 'formes_supplémentaires':'formes_supplémentaires.csv', 'hapax': 'hapax.csv'} self.result = {} for key in lcle : - with codecs.open(self.pathout[lcle[key]], 'r', sys.getdefaultencoding()) as f : + with open(self.pathout[lcle[key]], 'r', encoding='utf-8') as f : self.result[key] = [line.split(';') for line in f.read().splitlines()] self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])]) - with open(self.pathout['glob.txt'], 'r') as f : + with open(self.pathout['glob.txt'], 'r', encoding='utf-8') as f : self.result['glob'] = f.read() @@ -1324,7 +1325,7 @@ class SimiLayout(DefaultTextLayout) : #saveAsGEXF(graph, filepath = fileout) """ % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout) filetmp = tempfile.mktemp() - with open(filetmp, 'w') as f : + with open(filetmp, 'w', encoding='utf8') as f : f.write(txt) exec_rcode(self.ira.RPath, filetmp) mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK)