projects
/
iramuteq
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
...
[iramuteq]
/
chemins.py
diff --git
a/chemins.py
b/chemins.py
index
57e31c9
..
9c5dee7
100644
(file)
--- a/
chemins.py
+++ b/
chemins.py
@@
-1,16
+1,30
@@
-#!/bin/env python
# -*- coding: utf-8 -*-
#Author: Pierre Ratinaud
# -*- coding: utf-8 -*-
#Author: Pierre Ratinaud
-#Copyright (c) 2008 Pierre Ratinaud
-#Lisense: GNU/GPL
+#Copyright (c) 2008-2020 Pierre Ratinaud
+#modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
+#License: GNU/GPL
+#------------------------------------
+# import des modules python
+#------------------------------------
import os
import os
+import sys
import tempfile
import logging
import tempfile
import logging
+
log = logging.getLogger('iramuteq.chemins')
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 :
class PathOut :
def __init__(self, filename = None, analyse_type = '', dirout = None) :
if filename is not None :
@@
-20,22
+34,30
@@
class PathOut :
self.filename, self.fileext = os.path.splitext(self.filebasename)
self.analyse = analyse_type
#self.dirout = self.mkdirout(dirout)
self.filename, self.fileext = os.path.splitext(self.filebasename)
self.analyse = analyse_type
#self.dirout = self.mkdirout(dirout)
- if dirout is not None:
- self.dirout =
dirout
+ if dirout is not None:
+ self.dirout =
os.path.abspath(dirout)
elif filename is not None and dirout is None:
elif filename is not None and dirout is None:
- self.dirout =
self.directory
- self.d = {}
+ self.dirout =
os.path.abspath(self.directory)
+ self.d = {}
def mkdirout(self) :
dirout = os.path.join(self.dirout, self.filename + '_' + self.analyse + '_')
nb = 1
def mkdirout(self) :
dirout = os.path.join(self.dirout, self.filename + '_' + self.analyse + '_')
nb = 1
- tdirout = dirout +
`nb`
+ tdirout = dirout +
repr(nb)
while os.path.exists(tdirout) :
nb += 1
while os.path.exists(tdirout) :
nb += 1
- tdirout = dirout +
`nb`
+ tdirout = dirout +
repr(nb)
self.name = os.path.splitext(tdirout)[1]
return tdirout
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) :
os.mkdir(tdirout)
def createdir(self, tdirout) :
if not os.path.exists(tdirout) :
os.mkdir(tdirout)
@@
-48,20
+70,40
@@
class PathOut :
self.temp = tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\')
return self.temp
elif key not in self.d :
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 :
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('\\', '/')
def getF(self, key) :
return self.__getitem__(key).replace('\\', '/')
-
def ffr(filename):
return filename.replace('\\', '\\\\')
def ffr(filename):
return filename.replace('\\', '\\\\')
-
+
def FFF(filename):
return filename.replace('\\', '/')
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@@@@@@@@@@@@@@@@')
def ConstructRscriptsPath(AppliPath):
RScriptsPath = os.path.join(AppliPath, 'Rscripts')
#print('@@@@@@@@@@@PONDERATION CHDPOND.R@@@@@@@@@@@@@@@@')
@@
-112,7
+154,7
@@
def ConstructConfigPath(AppliPath, user=True):
else :
ConfigPath = AppliPath
DictConfigPath = {
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'),
'key': os.path.join(ConfigPath, 'key.cfg'),
'path': os.path.join(ConfigPath, 'path.cfg'),
'preferences' : os.path.join(ConfigPath, 'iramuteq.cfg'),
@@
-120,6
+162,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'),
'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
}
return DictConfigPath
@@
-127,6
+170,7
@@
def ConstructGlobalPath(AppliPath):
ConfigPath = os.path.join(AppliPath, 'configuration')
DictConfigPath = {
'global': os.path.join(ConfigPath, 'global.cfg'),
ConfigPath = os.path.join(AppliPath, 'configuration')
DictConfigPath = {
'global': os.path.join(ConfigPath, 'global.cfg'),
+ 'preferences': os.path.join(ConfigPath, 'iramuteq.cfg'),
}
return DictConfigPath
}
return DictConfigPath
@@
-147,6
+191,10
@@
def ConstructDicoPath(AppliPath):
'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'),
'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
}
return DictPath
@@
-193,7
+241,7
@@
ChdTxtPathOut = {'TableUc1': 'TableUc1.csv',
'rapport': 'RAPPORT.txt',
'pre_rapport' : 'info.txt',
'uce': 'uce.csv',
'rapport': 'RAPPORT.txt',
'pre_rapport' : 'info.txt',
'uce': 'uce.csv',
- 'Rchdtxt':
ffr(tempfile.mkstemp(prefix='iramuteq')[1]
),
+ 'Rchdtxt':
tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\'
),
'arbre1': 'arbre_1.png',
'arbre2': 'arbre_2.png',
'dendro1': 'dendro1.png',
'arbre1': 'arbre_1.png',
'arbre2': 'arbre_2.png',
'dendro1': 'dendro1.png',
@@
-217,13
+265,13
@@
ChdTxtPathOut = {'TableUc1': 'TableUc1.csv',
'AFC2DCoulSup': 'AFC2DCoulSup.png',
'AFC2DCoulEt': 'AFC2DCoulEt.png',
'AFC2DCoulCl': 'AFC2DCoulCl.png',
'AFC2DCoulSup': 'AFC2DCoulSup.png',
'AFC2DCoulEt': 'AFC2DCoulEt.png',
'AFC2DCoulCl': 'AFC2DCoulCl.png',
- 'Rafc3d':
ffr(tempfile.mkstemp(prefix='iramuteq')[1]
),
- 'R3DCoul':
ffr(tempfile.mkstemp(prefix='iramuteq')[1]
),
+ 'Rafc3d':
tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\'
),
+ 'R3DCoul':
tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\'
),
'RESULT_CHD': 'resultats-chd.html',
'RESULT_AFC': 'resultats-afc.html',
'Et01': 'Et01.csv',
'RESULT_CHD': 'resultats-chd.html',
'RESULT_AFC': 'resultats-afc.html',
'Et01': 'Et01.csv',
- 'Rchdquest':
ffr(tempfile.mkstemp(prefix='iramuteq')[1]
),
- 'RTxtProfGraph':
ffr(tempfile.mkstemp(prefix='iramuteq')[1]
),
+ 'Rchdquest':
tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\'
),
+ 'RTxtProfGraph':
tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\'
),
'typelist': 'typelist.csv',
'concord':'concordancier.csv',
'bduceforme':'bduceforme.csv',
'typelist': 'typelist.csv',
'concord':'concordancier.csv',
'bduceforme':'bduceforme.csv',
@@
-271,6
+319,7
@@
def StatTxtPathOut(pathout):
}
return d
}
return d
+# ???
#def construct_simipath(pathout):
# d = {'mat01' : 'mat01.csv',
# 'matsimi' : 'matsimi.csv',
#def construct_simipath(pathout):
# d = {'mat01' : 'mat01.csv',
# 'matsimi' : 'matsimi.csv',