rinominata variabile

This commit is contained in:
2020-03-25 12:03:55 +01:00
parent 4351e10984
commit f65fa21400

View File

@@ -20,7 +20,7 @@ class bananaSPLITTER(QThread):
self.log = logger
self.rawFile = None
self.status = "first"
self.fileList = list()
self.contentList = list()
self.bodyCounter=0
self.duplicateNumber=0
if fileParams is not None:
@@ -47,9 +47,9 @@ class bananaSPLITTER(QThread):
self.log.info("Controllo se ci sono dei duplicati..")
self.removeDuplicates()
else:
for idx, ff in enumerate(self.fileList):
for idx, ff in enumerate(self.contentList):
ff['duplicate']=False
self.fileList[idx]=ff
self.contentList[idx]=ff
self.log.warn('Salto il controllo dei duplicati..')
# se il parse e la rimozione dei duplicati e' andata bene
# preparo e inizio il salvataggio
@@ -203,7 +203,7 @@ class bananaSPLITTER(QThread):
if self.settings['delWordBreak']:
tempContent=[ll.replace('-\n', '') for ll in tempContent]
newDoc['content']=copy.deepcopy(''.join(tempBody))
self.fileList.append(copy.deepcopy(newDoc))
self.contentList.append(copy.deepcopy(newDoc))
tempBody=list()
self.bodyCounter +=1
pass
@@ -221,11 +221,11 @@ class bananaSPLITTER(QThread):
def removeDuplicates(self):
titleList=[]
duplicateList=[]
for idx, ff in enumerate(self.fileList):
for idx, ff in enumerate(self.contentList):
if ff['title'] not in titleList:
titleList.append(ff['title'])
ff['duplicate']=False
self.fileList[idx]=ff
self.contentList[idx]=ff
pass
else:
if ff['title'] not in duplicateList:
@@ -233,7 +233,7 @@ class bananaSPLITTER(QThread):
if self.settings['showRemovedDuplicates']:
self.log.info("Duplicato: {}".format(ff['title'].strip()))
ff['duplicate'] = True
self.fileList[idx]=ff
self.contentList[idx]=ff
self.duplicateNumber+=1
self.log.info("Ho rimosso {} duplicati di {} articoli..". format(self.duplicateNumber, len(duplicateList)))
pass
@@ -243,7 +243,7 @@ class bananaSPLITTER(QThread):
self.paths['OUTworkPath']=self.paths['OUTworkPath']+slugify(self.fileName)
self.log.info("Salvo gli articoli in file separati...")
self.log.debug("Persorso: {0}".format(self.paths['OUTworkPath'].format('nomeFile')))
for ff in self.fileList:
for ff in self.contentList:
try:
if ff['duplicate'] == False:
fName=self.paths['OUTnameFormat'].format(title=slugify(ff['title'][:self.settings['maxTitleLen']]),\
@@ -271,7 +271,7 @@ class bananaSPLITTER(QThread):
try:
fName=slugify(self.fileName)
fName='BODYFILE_{0}.txt'.format(fName[:self.settings['maxTitleLen']])
fileContent = os.linesep.join([cc['content'] for cc in self.fileList])
fileContent = os.linesep.join([cc['content'] for cc in self.contentList])
out=open('{0}'.format(fName),'wb')
out.write(fileContent.encode(self.settings['encoding']))
out.close()