From: Pierre Ratinaud Date: Mon, 15 Dec 2014 20:01:37 +0000 (+0100) Subject: ... X-Git-Url: http://iramuteq.org/git?a=commitdiff_plain;h=aae91ab48172a83c49bb502ac737bcc1b3a6685c;p=iramuteq ... --- diff --git a/corpus.py b/corpus.py index 6e667b3..3ced482 100644 --- a/corpus.py +++ b/corpus.py @@ -539,6 +539,14 @@ class Corpus : ident += 1 f.write('\n'.join([self.ucis[self.iduces[uce[0]].uci].paras[ident].encode(self.parametres['syscoding']), uce[1].encode(self.parametres['syscoding'])]) + '\n') + def export_meta_table(self, outf) : + metas = [[`i`] + text.etoiles[1:] for i, text in enumerate(self.ucis)] + longueur_max = max([len(val) for val in metas]) + first = ['column_%i' % i for i in range(longueur_max)] + metas.insert(0, first) + with open(outf, 'w') as f : + f.write('\n'.join(['\t'.join(line) for line in metas]).encode(self.parametres['syscoding'])) + def export_corpus_classes(self, outf, alc = True, lem = False, uci = False) : ucecl = {} for i, lc in enumerate(self.lc) : diff --git a/functions.py b/functions.py index 8cd7352..62f669c 100644 --- a/functions.py +++ b/functions.py @@ -30,6 +30,14 @@ log = logging.getLogger('iramuteq') indices_simi = [u'cooccurrence' ,'pourcentage de cooccurrence',u'Russel',u'Jaccard', 'Kulczynski1', 'Kulczynski2', 'Mountford', 'Fager', 'simple matching', 'Hamman', 'Faith', 'Tanimoto', 'Dice', 'Phi', 'Stiles', 'Michael', 'Mozley', 'Yule', 'Yule2', 'Ochiai', 'Simpson', 'Braun-Blanquet','Chi-squared', 'Phi-squared', 'Tschuprow', 'Cramer', 'Pearson', 'binomial'] + +def open_folder(folder): + if sys.platform == "win32": + os.startfile(folder) + else: + opener ="open" if sys.platform == "darwin" else "xdg-open" + call([opener, folder]) + def normpath_win32(path) : if not sys.platform == 'win32' : return path diff --git a/guifunct.py b/guifunct.py index 9fb70b0..afb7f07 100644 --- a/guifunct.py +++ b/guifunct.py @@ -7,7 +7,7 @@ import wx import os import sys from copy import copy -import dialog +from dialog import FileOptionDialog, SelectColDial, OptLexi, PrefSimpleFile from listlex import * from vitemspicker import VItemsPicker, EVT_IP_SELECTION_CHANGED, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES from functions import treat_var_mod @@ -49,7 +49,7 @@ def getfileextension(file) : def get_table_param(self, filename) : if getfileextension(filename) == '.csv': - dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200), + dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE) dlg.CenterOnParent() val = dlg.ShowModal() @@ -61,7 +61,7 @@ def get_table_param(self, filename) : self.tableau.parametres['filetype'] = 'csv' self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()] elif getfileextension(filename) == '.xls' : - dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200), + dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE) dlg.CenterOnParent() val = dlg.ShowModal() @@ -72,7 +72,7 @@ def get_table_param(self, filename) : self.tableau.parametres['sheetnb'] = dlg.spin1.GetValue() self.tableau.parametres['filetype'] = 'xls' elif getfileextension(filename) == '.ods': - dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200), + dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE) dlg.CenterOnParent() val = dlg.ShowModal() @@ -116,7 +116,7 @@ class SelectColumn : def __init__(self, parent, dictcol, actives, pathout, selected = None, dlg = False) : self.ira = parent if dlg : - dial = dialog.SelectColDial(self.ira) + dial = SelectColDial(self.ira) listcol = ListForSpec(dial, self, dictcol, ['eff']) dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 ) dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK ) @@ -897,7 +897,7 @@ class PrepSimi : if 'bystar' in self.parametres : if self.dial.check_bystar.GetValue() : variables = treat_var_mod(self.parametres['stars']) - vardial = dialog.OptLexi(parent, force_chi = True) + vardial = OptLexi(parent, force_chi = True) vardial.listet = self.parametres['stars'] vardial.variables = [v for v in variables] for et in vardial.variables : @@ -1236,3 +1236,21 @@ class TGenFrame ( wx.Frame ): self.tgens.Append(self.dial.m_textCtrl1.GetValue()) self.dial.Destroy() evt.Skip() + +class ExportMetaTable : + def __init__(self, parent, corpus): + self.ira = parent + dial = PrefSimpleFile(self, self.ira, **{'mask' : '*.csv', 'title': _(u"meta-data table").decode('utf8')}) + dial.fbb.SetValue(corpus.pathout['metadata.csv']) + dial.CenterOnParent() + res = dial.ShowModal() + if res == wx.ID_OK : + fileout = dial.fbb.GetValue() + dial.Destroy() + corpus.export_meta_table(fileout) + dlg = wx.MessageDialog(self.ira, _("Done !").decode('utf8'), _(u"Export meta-data").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) + dlg.CenterOnParent() + dlg.ShowModal() + dlg.Destroy() + else : + dial.Destroy() diff --git a/iramuteq.py b/iramuteq.py index e5d145b..f9515ad 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -96,6 +96,7 @@ ID_ImportEuro = wx.NewId() ID_Fact_xml = wx.NewId() ID_Fact_mail = wx.NewId() ID_Fact_copy = wx.NewId() +ID_exportmeta = wx.NewId() ########################################################## #elements de configuration ########################################################## @@ -317,7 +318,8 @@ class IraFrame(wx.Frame): 'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]}, [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'], [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'], - [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta']] + [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'], + ] for analyse in matanalyses : if not isinstance(analyse, dict) : @@ -367,6 +369,7 @@ class IraFrame(wx.Frame): {'name' : _(u"Sub corpus").decode('utf8'), 'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'], [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]}, + [ID_exportmeta, _(u"Export meta-data table").decode('utf8'), None], ] for analyse in analyses_text : @@ -589,6 +592,7 @@ class IraFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES) self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM) self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro) + self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta) self.Bind(wx.EVT_CLOSE, self.OnClose) ################################################################## flags = self._mgr.GetAGWFlags() @@ -1096,6 +1100,14 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" ImportFactiva(self, 'euro') except : BugReport(self) + + def OnExportMeta(self, evt, corpus = None): + if corpus is None : + corpus = self.tree.getcorpus() + try : + ExportMetaTable(self, corpus) + except : + BugReport(self) def ExtractTools(self, evt) : ID = evt.GetId() diff --git a/tree.py b/tree.py index 83f7d6e..0745ebd 100644 --- a/tree.py +++ b/tree.py @@ -11,7 +11,7 @@ import logging from openanalyse import OpenAnalyse from corpus import Corpus, copycorpus from tableau import Tableau, copymatrix -from functions import DoConf, GetTxtProfile, TGen, BugReport +from functions import DoConf, GetTxtProfile, TGen, BugReport, open_folder from profile_segment import ProfileSegment, ProfilType from search_tools import SearchFrame from dialog import PrefSimpleFile, PrefExport @@ -399,6 +399,11 @@ class LeftTree(CT.CustomTreeCtrl): rename = wx.MenuItem(menu, wx.ID_ANY, _(u"Rename").decode('utf8')) rename.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_TIP, size = (16,16))) menu.AppendItem(rename) + + openfolder = wx.MenuItem(menu, wx.ID_ANY, _(u"Open directory").decode('utf8')) + openfolder.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FOLDER_OPEN, size = (16,16))) + menu.AppendItem(openfolder) + menu.AppendSeparator() if 'corpus_name' in pydata : @@ -473,6 +478,7 @@ class LeftTree(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OnItemInfo, info) self.Bind(wx.EVT_MENU, self.OnRename, rename) self.Bind(wx.EVT_MENU, self.OnItemDelete, itemdelete) + self.Bind(wx.EVT_MENU, self.OnOpenFolder, openfolder) #self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11) #self.Bind(wx.EVT_MENU, self.OnItemAppend, item12) @@ -738,6 +744,12 @@ class LeftTree(CT.CustomTreeCtrl): self.history.update(pydata) self.SetItemText(self.current, newname) self.EnsureVisible(self.current) + + def OnOpenFolder(self, evt): + try : + open_folder(os.path.dirname(self.pydata['ira'])) + except : + print 'cannot open folder %s' % self.pydata.get('ira', 'noirapath') def OnItemBackground(self, event):