def write(self, overwrite=False): """Write ebuild file :param overwrite: Overwrite ebuild if it already exists. :type overwrite: bool """ # get ebuild path if not self.ebuild_path: overlay_name = self.options.overlay overlay_path = PortageUtils.get_overlay_path(overlay_name) self.ebuild_path = self.find_path_to_ebuild(overlay_path) log.debug('Ebuild.write: build_path(%s)', self.ebuild_path) # see if we want to overwrite if (not self.options.command == 'echo') and os.path.exists(self.ebuild_path) and not overwrite: log.warn("Ebuild exists (use -o to overwrite), skipping: %s" % self.ebuild_path) return False # write ebuild out = open(self.ebuild_path, "w") try: out.write(self.render()) finally: out.close() return True