示例#1
0
    def testReadFile(self):
        dataMap = DataMap()
        dataMap.readFile(TestDataMap.IMAPLIST)

        self.assertEqual(2, len(dataMap.dataMap))
        self.assertEqual(2, len(dataMap.dataMap['audio1']))
        self.assertEqual(2, len(dataMap.dataMap['audio1']['segment1']))
示例#2
0
	def testReadFile(self):
		dataMap = DataMap()
		dataMap.readFile(TestDataMap.IMAPLIST)
		
		self.assertEqual(2, len(dataMap.dataMap))
		self.assertEqual(2, len(dataMap.dataMap['audio1']))
		self.assertEqual(2, len(dataMap.dataMap['audio1']['segment1']))
示例#3
0
    def testWriteFile(self):
        dataMap = DataMap()
        dataMap.readFile(TestDataMap.IMAPLIST)
        dataMap.writeFile(TestDataMap.OMAPLIST)

        tempDataMap = copy.deepcopy(dataMap.dataMap)

        dataMap.readFile(TestDataMap.OMAPLIST)

        dataMap = dataMap.dataMap

        self.compareDict(tempDataMap, dataMap)
        self.compareDict(dataMap, tempDataMap)
示例#4
0
	def testWriteFile(self):
		dataMap = DataMap()
		dataMap.readFile(TestDataMap.IMAPLIST)
		dataMap.writeFile(TestDataMap.OMAPLIST)

		tempDataMap = copy.deepcopy(dataMap.dataMap)

		dataMap.readFile(TestDataMap.OMAPLIST)

		dataMap = dataMap.dataMap

		self.compareDict(tempDataMap, dataMap)
		self.compareDict(dataMap, tempDataMap)
示例#5
0
    def testSetDictionaryMapFromList(self):
        dataList = [['audio1', 'segment1', 'mlf1'],
                    ['audio1', 'segment1', 'mlf2'],
                    ['audio1', 'segment2', 'mlf3'],
                    ['audio1', 'segment2', 'mlf4'],
                    ['audio2', 'segment3', 'mlf5'],
                    ['audio2', 'segment3', 'mlf6'],
                    ['audio2', 'segment4', 'mlf8'],
                    ['audio2', 'segment4', 'mlf7']]

        dataMap = DataMap()
        dataMap.readFile(TestDataMap.IMAPLIST)
        tempDataMap = copy.deepcopy(dataMap.dataMap)

        dataMap.setDictionaryMapFromList(dataList)
        dataMap = dataMap.dataMap

        self.compareDict(tempDataMap, dataMap)
        self.compareDict(dataMap, tempDataMap)
示例#6
0
	def testSetDictionaryMapFromList(self):
		dataList = [['audio1', 'segment1', 'mlf1'],
				   ['audio1', 'segment1', 'mlf2'],
				   ['audio1', 'segment2', 'mlf3'],
				   ['audio1', 'segment2', 'mlf4'],
				   ['audio2', 'segment3', 'mlf5'],
				   ['audio2', 'segment3', 'mlf6'],
				   ['audio2', 'segment4', 'mlf8'],
				   ['audio2', 'segment4', 'mlf7']]

		dataMap = DataMap()
		dataMap.readFile(TestDataMap.IMAPLIST)
		tempDataMap = copy.deepcopy(dataMap.dataMap)

		dataMap.setDictionaryMapFromList(dataList)
		dataMap = dataMap.dataMap

		self.compareDict(tempDataMap, dataMap)
		self.compareDict(dataMap, tempDataMap)
示例#7
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))