X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=chemins.py;h=f43969cc956ac828ecafe922ce79db68a0e00dda;hp=014d009d3444948fc2aaec00e91a1fc81fcc5fc1;hb=b5c29c4ff9eaa0979a0bb524d9395301c447783d;hpb=eb798ba97d92c40656cedc5414974a9edf7a332c diff --git a/chemins.py b/chemins.py index 014d009..f43969c 100644 --- a/chemins.py +++ b/chemins.py @@ -5,12 +5,22 @@ #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) : @@ -48,9 +58,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('\\', '/') @@ -129,7 +143,7 @@ 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'), @@ -137,6 +151,7 @@ def ConstructConfigPath(AppliPath, user=True): '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 @@ -144,6 +159,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