From 232108a6f41a627d652fd8ad9d0cb43e4eb52118 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Wed, 25 Mar 2020 16:28:07 +0100 Subject: [PATCH] forse tolti tutti i os.chdir --- TestFiles/README | 1 - bananaSPLIT/conf/defaults.json | 2 +- bananaSPLIT/libbananasplit/libsplit.py | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 TestFiles/README diff --git a/TestFiles/README b/TestFiles/README deleted file mode 100644 index 8f1c4dd..0000000 --- a/TestFiles/README +++ /dev/null @@ -1 +0,0 @@ -Qui si mettono i file di test per la versione GUI di bananaSPLIT \ No newline at end of file diff --git a/bananaSPLIT/conf/defaults.json b/bananaSPLIT/conf/defaults.json index 0b07287..d59cd45 100644 --- a/bananaSPLIT/conf/defaults.json +++ b/bananaSPLIT/conf/defaults.json @@ -3,7 +3,7 @@ "paths": { "lastUsed": "defaults.json", "configurationPath": "D:/Emanuele/Documenti/workspace/bananaSPLIT/bananaSPLIT/conf/", - "INworkPath": "D:/Emanuele/Documenti/workspace/bananaSPLIT/TestFiles", + "INworkPath": "D:/Emanuele/Documenti/workspace/bananaSPLIT/TestFiles/", "OUTworkPath": "H:/", "fileList": [ "GUARDIAN 1993.txt", diff --git a/bananaSPLIT/libbananasplit/libsplit.py b/bananaSPLIT/libbananasplit/libsplit.py index ae17edc..2059517 100644 --- a/bananaSPLIT/libbananasplit/libsplit.py +++ b/bananaSPLIT/libbananasplit/libsplit.py @@ -57,14 +57,14 @@ class bananaSPLITTER(QThread): # preparo e inizio il salvataggio if os.path.exists(self.outPath): if self.settings['removeOldFiles']: - os.chdir(self.outPath) + #os.chdir(self.outPath) for f in os.listdir(self.outPath): os.remove(f) else: raise FileExistsError("Non posso sovrascrivere i vecchi file, eliminali manualmente!") else: os.mkdir(self.outPath) - os.chdir(self.outPath) + #os.chdir(self.outPath) if self.settings['saveSeparateFiles']: self.saveSeparate() if self.settings['saveBodyFile']: @@ -83,9 +83,9 @@ class bananaSPLITTER(QThread): def openFile(self): try: - os.chdir(self.paths["INworkPath"]) + #os.chdir(self.paths["INworkPath"]) self.log.info("Carico il contenuto..") - fp = open(self.fileParams['name'], mode='r', encoding=self.settings['encoding']) + fp = open(self.paths["INworkPath"]+'/'+self.fileParams['name'], mode='r', encoding=self.settings['encoding']) self.rawFile = fp.readlines() fp.close() except IOError as e: @@ -253,7 +253,7 @@ class bananaSPLITTER(QThread): docnum=outFileCounter,\ papername=ff['newsPaperName'].strip(),\ **ff['date']) - out=open('{0}'.format(fName),'wb') + out=open(self.outPath+'{0}'.format(fName),'wb') if self.settings['includeTitle']: ff['content'] = ff['title']+os.linesep+ff['content'] out.write(ff['content'].encode(self.settings['encoding'])) @@ -276,7 +276,7 @@ class bananaSPLITTER(QThread): self.log.debug('Persorso: {0}'.format(self.outPath)) os.chdir(self.outPath) try: - fName=slugify(self.fileName) + fName=self.outPath+slugify(self.fileName) fName='BODYFILE_{0}.txt'.format(fName[:self.docStruct['maxTitleLen']]) fileContent = os.linesep.join([cc['content'] for cc in self.contentList]) out=open('{0}'.format(fName),'wb')