Ejemplo n.º 1
0
	def testAppend(self):
		"""
		This method tests :meth:`foundations.io.File.append` method.
		"""

		ioFile = File(tempfile.mkstemp()[1])
		self.assertIsInstance(ioFile.content, list)
		ioFile.content = FILE_CONTENT
		ioFile.write()
		append = ioFile.append()
		self.assertTrue(append)
		ioFile.read()
		self.assertListEqual(ioFile.content, FILE_CONTENT + FILE_CONTENT)
		os.remove(ioFile.file)
Ejemplo n.º 2
0
    def testAppend(self):
        """
		Tests :meth:`foundations.io.File.append` method.
		"""

        fileDescriptor, path = tempfile.mkstemp()
        ioFile = File(unicode(path))
        self.assertIsInstance(ioFile.content, list)
        ioFile.content = FILE_CONTENT
        ioFile.write()
        append = ioFile.append()
        self.assertTrue(append)
        ioFile.cache()
        self.assertListEqual(ioFile.content, FILE_CONTENT + FILE_CONTENT)
        os.close(fileDescriptor)
Ejemplo n.º 3
0
	def applyPatch(self, patch):
		"""
		Applies given patch.

		:param patch: Patch.
		:type patch: Patch
		:return: Method success.
		:rtype: bool
		"""

		historyFile = File(self.__historyFile)
		patchesHistory = historyFile.cache() and [line.strip() for line in historyFile.content] or []

		if patch.uid not in patchesHistory:
			LOGGER.debug("> Applying '{0}' patch!".format(patch.name))
			if patch.apply():
				historyFile.content = ["{0}\n".format(patch.uid)]
				historyFile.append()
			else:
				raise umbra.exceptions.PatchApplyError("{0} | '{1}' patch failed to apply!".format(
					self.__class__.__name__, patch.path))
		else:
			LOGGER.debug("> '{0}' patch is already applied!".format(patch.name))
		return True