diff --git a/lib/WPImport.py b/lib/WPImport.py index 749a88b..60c79b9 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -59,10 +59,17 @@ class WPimport: def fromFile(self, files=[], number_thread=1, max_thread=1): + divFiles = int(len(files) / max_thread) + currentRangeFiles = int(divFiles * (number_thread+1)) + firstRange = int(currentRangeFiles - divFiles) + self._logger.debug("{0} : index : {1}".format(self._name,number_thread)) - for i in range(0, len(files)): + self._logger.debug("{0} : first range : {1}".format(self._name,firstRange)) + self._logger.debug("{0} : last range : {1}".format(self._name,currentRangeFiles)) + + for i in range(firstRange, currentRangeFiles): if os.path.exists(files[i]): - self._logger.info("{0} : ({1}/{2}) File is being processed : {3}".format(self._name, i+1, len(files), files[i])) + self._logger.info("{0} : ({1}/{2}) File is being processed : {3}".format(self._name, i+1, currentRangeFiles + 1, files[i])) with open(files[i], 'r') as f: content = f.read() self._logger.debug("{0} : Size of article : {1}".format(self._name, len(content)))