<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_file(self, path, contents):
 		""" 		Write a file of any type to the destination path. Useful for files like 		robots.txt, manifest.json, and so on. 		Args: 		 path (str):
 The name of the file to write to. 		 contents (str or bytes):
 The contents to write. 		"""

		path = self._get_dist_path(path)
		if not os.path.isdir(os.path.dirname(path)):
			os.makedirs(os.path.dirname(path))
		if isinstance(contents, bytes):
			mode = 'wb+'
		else:
			mode = 'w'
		with open(path, mode) as file:
			file.write(contents)