From 8628c3dbfb2cc2fec60b0951ec5773e322529937 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Sun, 1 Dec 2019 18:29:09 +0100 Subject: [PATCH] risolti i problemi di parsign su file di esempio semplificato --- bananaSPLIT/libbananasplit/libsplit.py | 9 +++------ bananaSPLIT/libbananasplit/testEN.json | 4 ++-- bananaSPLIT/libtestmain.py | 9 ++++++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bananaSPLIT/libbananasplit/libsplit.py b/bananaSPLIT/libbananasplit/libsplit.py index 0a98068..5c95994 100644 --- a/bananaSPLIT/libbananasplit/libsplit.py +++ b/bananaSPLIT/libbananasplit/libsplit.py @@ -107,7 +107,7 @@ class bananaSPLITTER(threading.Thread): # ricerco la data if (lineWords[self.settings['monthPosition']]).capitalize() in self.docStruct['dateWords']: try: - docDate=parse.parse(self.docParams['dateFormat'],l).named + docDate=parse.parse(self.docStruct['dateFormat'],l).named docDate['month']=docDate['month'].lstrip().rstrip().capitalize() docDate['month']=self.docStruct['dateWords'].index(docDate['month'])+1 title = '' @@ -231,7 +231,7 @@ class bananaSPLITTER(threading.Thread): print ('Persorso: {0}'.format(self.paths['OUTworkPath'].format('nomeFile'))) try: fName=slugify(self.fileName) - fName='BODYFILE_{0}_{1}.txt'.format(self.fileCounter,fName[:self.settings['maxTitleLen']]) + fName='BODYFILE_{0}.txt'.format(fName[:self.settings['maxTitleLen']]) fileContent = os.linesep.join([cc['content'] for cc in self.fileList]) out=open(self.paths['OUTworkPath']+'{0}'.format(fName),'wb') out.write(fileContent.encode(self.settings['encoding'])) @@ -239,9 +239,6 @@ class bananaSPLITTER(threading.Thread): except IOError as e: print("OOPS! Qualcosa e\' andato storto, non riesco a scrivere il file: {}".format(e)) pass - -if __name__ == "__main__": - logg = fancyLogger(name="LibSplit") - spp = bananaSPLITTER(fileParams="testfile.txt", logger=logg) + \ No newline at end of file diff --git a/bananaSPLIT/libbananasplit/testEN.json b/bananaSPLIT/libbananasplit/testEN.json index a8f7c39..aa500ed 100644 --- a/bananaSPLIT/libbananasplit/testEN.json +++ b/bananaSPLIT/libbananasplit/testEN.json @@ -58,7 +58,7 @@ "nameNotFoundStr": "ND", "includeTitle": true, "removeDuplicates": true, - "showSkipped": false, + "showSkipped": true, "showRemovedDuplicates": true, "maxTitleLen": 32, "loadTXT": true, @@ -67,7 +67,7 @@ "saveSeparateFiles": true, "saveBodyFile": true, "saveBodyNumber": true, - "delLF": false, + "delLF": true, "delWordBreak": true, "delChars": [ "'", diff --git a/bananaSPLIT/libtestmain.py b/bananaSPLIT/libtestmain.py index 9de7000..6183d4b 100644 --- a/bananaSPLIT/libtestmain.py +++ b/bananaSPLIT/libtestmain.py @@ -17,9 +17,12 @@ confl.use("testEN.json") splconf = confl.getParams("splitter") splconf["name"] = splconf["paths"]["INworkPath"]+"GUARDIAN 1989.txt" splitter = bananaSPLITTER(fileParams=splconf, logger=logger) -splitter.start() -splitter.join() - +splitter.openFile() +splitter.remEmptyLines() +splitter.splitFile() +splitter.removeDuplicates() +splitter.saveBody() +splitter.saveSeparate()