Beispiel #1
0
    def _readDataList(self):
        """Read the only data list from 'target directory'.
        """
        self._log(logging.INFO,
                  "Gather input lists from %s" % self.getTargetDirectory())

        #Input list
        dataListFiles = MyFile.dirContent(self.getTargetDirectory(),
                                          "*" + Task.OUTPUTLISTEXTENSION)

        #Input data or representations
        if len(dataListFiles) == 0:
            raise Exception("No data list found in %s!" %
                            self.getTargetDirectory())
        elif len(dataListFiles) > 1:
            raise Exception("One input list max, %d found!" %
                            len(dataListFiles))

        self._log(logging.INFO, "Found data list: %s!" % dataListFiles[0])

        #Copy from target directory
        dataListSrcPath = self.getTargetDirectory() + os.sep + dataListFiles[0]
        dataListDestPath = self.getInputDirectory() + os.sep +\
                           MyFile.removeExtension(dataListFiles[0])[0] + Task.INPUTLISTEXTENSION

        MyFile.copyFile(dataListSrcPath, dataListDestPath)

        #Read content
        self.inputList = DataList()
        self.inputList.readFile(dataListDestPath)
Beispiel #2
0
    def prepareOutputData(self):
        """Copy results, old lists and build new input
           and map lists.
        """
        self._log(logging.INFO, "Copy results files to output folder:%s" % self.getOutputDirectory())

        # Data maps
        dataMapFiles = MyFile.dirContent(self.getTempDirectory(), "*sentences_*.txt")
        for sentenceFile in dataMapFiles:
            srcFile = self.getTempDirectory() + os.sep + sentenceFile
            shutil.copy(srcFile, self.getOutputDirectory())
Beispiel #3
0
    def prepareOutputData(self):
        """Copy results, old lists and build new input
           and map lists.
        """
        self._log(logging.INFO, "Copy results files to output folder:%s" %
                        self.getOutputDirectory())

        #Data maps
        dataMapFiles = MyFile.dirContent(self.getTempDirectory(),
                                         "*sentences_*.txt")
        for sentenceFile in dataMapFiles:
            srcFile = self.getTempDirectory() + os.sep + sentenceFile
            shutil.copy(srcFile,self.getOutputDirectory())
Beispiel #4
0
    def _readMapLists(self):
        """Read the data maps from 'target directory'.
        """
        #Data maps
        dataMapFiles = MyFile.dirContent(self.getTargetDirectory(),
                                         "*" + Task.OUTPUTMAPEXTENSION)

        #Map of representations for data
        if len(dataMapFiles) == 0:
            raise Exception("No data map found in %s!" %
                            self.getTargetDirectory())

        self._log(logging.INFO,
                  "Found %d input map list(s)!" % len(dataMapFiles))

        for dataMapFile in dataMapFiles:
            self._log(logging.INFO, "Found map list: %s!" % dataMapFile)

            #Copy from target directory
            dataMapSrcPath = self.getTargetDirectory() + os.sep + dataMapFile
            dataMapDestPath = self.getInputDirectory() + os.sep +\
                              MyFile.removeExtension(dataMapFile)[0] + Task.INPUTMAPEXTENSION

            MyFile.copyFile(dataMapSrcPath, dataMapDestPath)

            #Read content
            tempDataMap = DataMap()
            tempDataMap.readFile(dataMapDestPath)
            self.mapLists.append(tempDataMap)

        self._log(logging.INFO,
                  "Lists have been copied to %s" % self.getInputDirectory())

        #Debug information
        dataListFiles = MyFile.dirContent(self.getInputDirectory(), "*")
        self._log(logging.INFO,
                  "Files in input directory: '%s'." % ", ".join(dataListFiles))