X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=chemins.py;h=4e50a484fe604d51c3a1a033b72249c3231c75a8;hp=b7c288d722999502b71bb2c5d981aba9ffb0a1dc;hb=287f9e72c3e3d666b016dff0fa3dc39419adfcc2;hpb=8fa853a25a9d62b1446e1bc543e5a3a4d0e03dcf diff --git a/chemins.py b/chemins.py index b7c288d..4e50a48 100644 --- a/chemins.py +++ b/chemins.py @@ -2,15 +2,25 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2008 Pierre Ratinaud -#Lisense: GNU/GPL +#License: GNU/GPL import os +import sys import tempfile import logging log = logging.getLogger('iramuteq.chemins') +def normpath_win32(path) : + if not sys.platform == 'win32' : + return path + while '\\\\' in path : + path = path.replace('\\\\', '\\') + if sys.platform == 'win32' and path.startswith('\\') and not path.startswith('\\\\') : + path = '\\' + path + return path + class PathOut : def __init__(self, filename = None, analyse_type = '', dirout = None) : if filename is not None : @@ -21,9 +31,9 @@ class PathOut : self.analyse = analyse_type #self.dirout = self.mkdirout(dirout) if dirout is not None: - self.dirout = dirout + self.dirout = os.path.abspath(dirout) elif filename is not None and dirout is None: - self.dirout = self.directory + self.dirout = os.path.abspath(self.directory) self.d = {} def mkdirout(self) : @@ -35,6 +45,14 @@ class PathOut : tdirout = dirout + `nb` self.name = os.path.splitext(tdirout)[1] return tdirout + + def makenew(self, filename, ext): + nb = 1 + newfile = '_'.join([os.path.join(self.dirout, filename), '%i' % nb]) + '.' + ext + while os.path.exists(newfile) : + nb += 1 + newfile = '_'.join([os.path.join(self.dirout, filename), '%i' % nb]) + '.' + ext + return newfile def createdir(self, tdirout) : if not os.path.exists(tdirout) : @@ -48,9 +66,13 @@ class PathOut : self.temp = tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\') return self.temp elif key not in self.d : - return os.path.join(self.dirout, key).replace('\\', '\\\\') + f = os.path.join(self.dirout, key).replace('\\', '\\\\') + return normpath_win32(f) + #return os.path.join(self.dirout, key).replace('\\', '\\\\') else : - return os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\') + f = os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\') + return normpath_win32(f) + #return os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\') def getF(self, key) : return self.__getitem__(key).replace('\\', '/') @@ -62,6 +84,23 @@ def ffr(filename): def FFF(filename): return filename.replace('\\', '/') +RscriptsPath = { + 'Rfunct': 'Rfunct.R', + 'chdfunct': 'chdfunct.R', + 'Rgraph': 'Rgraph.R', + 'plotafcm': 'plotafcm.R', + 'afc_graph' : 'afc_graph.R', + #'CHD': 'CHDPOND.R', + 'CHD': 'CHD.R', + #'CHD' : 'NCHD.R', + 'chdtxt': 'chdtxt.R', + 'chdquest': 'chdquest.R', + 'pamtxt' : 'pamtxt.R', + 'anacor' : 'anacor.R', + #'anacor' : 'Nanacor.R', + 'simi' : 'simi.R', + } + def ConstructRscriptsPath(AppliPath): RScriptsPath = os.path.join(AppliPath, 'Rscripts') #print('@@@@@@@@@@@PONDERATION CHDPOND.R@@@@@@@@@@@@@@@@') @@ -112,12 +151,15 @@ def ConstructConfigPath(AppliPath, user=True): else : ConfigPath = AppliPath DictConfigPath = { - 'alceste': os.path.join(ConfigPath, 'alceste.cfg'), + 'reinert': os.path.join(ConfigPath, 'reinert.cfg'), 'key': os.path.join(ConfigPath, 'key.cfg'), 'path': os.path.join(ConfigPath, 'path.cfg'), 'preferences' : os.path.join(ConfigPath, 'iramuteq.cfg'), 'pam' : os.path.join(ConfigPath, 'pam.cfg'), - 'history' : os.path.join(ConfigPath, 'history.db'), + 'corpus' : os.path.join(ConfigPath, 'corpus.cfg'), + 'stat' : os.path.join(ConfigPath, 'stat.cfg'), + 'simitxt' : os.path.join(ConfigPath, 'simitxt.cfg'), + 'matrix' : os.path.join(ConfigPath, 'matrix.cfg'), } return DictConfigPath @@ -125,6 +167,7 @@ def ConstructGlobalPath(AppliPath): ConfigPath = os.path.join(AppliPath, 'configuration') DictConfigPath = { 'global': os.path.join(ConfigPath, 'global.cfg'), + 'preferences': os.path.join(ConfigPath, 'iramuteq.cfg'), } return DictConfigPath @@ -139,6 +182,16 @@ def ConstructDicoPath(AppliPath): 'german_exp' : os.path.join(BasePath, 'expression_de.txt'), 'italian' : os.path.join(BasePath, 'lexique_it.txt'), 'italian_exp' : os.path.join(BasePath, 'expression_it.txt'), + 'swedish' : os.path.join(BasePath, 'lexique_sw.txt'), + 'swedish_exp' : os.path.join(BasePath, 'expression_sw.txt'), + 'portuguese' : os.path.join(BasePath, 'lexique_pt.txt'), + 'portuguese_exp': os.path.join(BasePath, 'expression_pt.txt'), + 'greek' : os.path.join(BasePath, 'lexique_gr.txt'), + 'greek_exp' : os.path.join(BasePath, 'expression_gr.txt'), + 'spanish' : os.path.join(BasePath, 'lexique_sp.txt'), + 'spanish_exp' : os.path.join(BasePath, 'expression_sp.txt'), + 'galician' : os.path.join(BasePath, 'lexique_gl.txt'), + 'galician_exp' : os.path.join(BasePath, 'expression_gl.txt'), } return DictPath @@ -213,7 +266,6 @@ ChdTxtPathOut = {'TableUc1': 'TableUc1.csv', 'R3DCoul': ffr(tempfile.mkstemp(prefix='iramuteq')[1]), 'RESULT_CHD': 'resultats-chd.html', 'RESULT_AFC': 'resultats-afc.html', - 'Act01': 'Act01.csv', 'Et01': 'Et01.csv', 'Rchdquest':ffr(tempfile.mkstemp(prefix='iramuteq')[1]), 'RTxtProfGraph':ffr(tempfile.mkstemp(prefix='iramuteq')[1]), @@ -264,15 +316,25 @@ def StatTxtPathOut(pathout): } return d -def construct_simipath(pathout): - d = {'mat01' : ffr(os.path.join(pathout, 'mat01.csv')), - 'matsimi' : ffr(os.path.join(pathout, 'matsimi.csv')), - 'eff' : ffr(os.path.join(pathout, 'eff.csv')), - 'RData' : ffr(os.path.join(pathout, 'RData.RData')), - 'liste_graph' : os.path.join(pathout, 'liste_graph.txt'), - 'ira' : os.path.join(pathout, 'Analyse.ira'), - 'film' : ffr(pathout), - 'db' : os.path.join(pathout, 'analyse.db'), - 'corpus' : os.path.join(pathout, 'corpus.db'), +#def construct_simipath(pathout): +# d = {'mat01' : 'mat01.csv', +# 'matsimi' : 'matsimi.csv', +# 'eff' : 'eff.csv', +# 'RData' : 'RData.RData', +# 'liste_graph' : 'liste_graph.txt', +# 'ira' : 'Analyse.ira', +# 'film' : '', +# 'db' : 'analyse.db', +# } + +simipath = {'mat01' : 'mat01.csv', + 'matsimi' : 'matsimi.csv', + 'eff' : 'eff.csv', + 'RData' : 'RData.RData', + 'liste_graph' :'liste_graph.txt', + 'ira' : 'Analyse.ira', + 'film' : '', + 'db' : 'analyse.db', + 'corpus' : 'corpus.db', } - return d +