1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| class ConteneurPaquet:
def __init__(self, path_fichier_tsv):
print path_fichier_tsv
tsvparser.TsvParser(path_fichier_tsv)
def __call__(self):
return '__call__'
class Calcul:
def __init__(self):
self.GoCalc()
def GoCalc(self):
TM = Conteneur()
RepertoireCourant = "D:\Documents and Settings\olivetr\My Documents\Test_calc"
RepertoireCourant = os.path.normpath(RepertoireCourant)
print RepertoireCourant
entrees = os.listdir(RepertoireCourant)
print entrees
prefixeTM = 'JAS1_HKTMR_2009_01'
liste = []
# On liste tous les paquets décommutés (fichier tsv créé)
for nf in entrees:
nfc = os.path.join(RepertoireCourant, nf)
#Si le fichier existe et si son extension est en .tsv
if os.path.isfile(nfc) and os.path.splitext(nfc)[-1]==".tsv":
liste.append(nfc)
# « liste » liste tous les fichiers tsv dans le répertoire courant
# il faut maintenant repérer le nom du paquet !
for path_tsv in liste :
tsv = os.path.basename(path_tsv)
tsv = os.path.splitext(tsv)[0]
tsv = tsv.split(prefixeTM+'_')[-1]
exec compile( 'TM.'+tsv+'=ConteneurPaquet('+str(path_tsv)+')', '', 'exec' ) |