# Path: sunflower/common.py
# def executable_exists(command):
# 	"""Check if specified command exists in search path"""
# 	default_paths = os.pathsep.join(('/bin', '/usr/bin', '/usr/local/bin'))
# 	search_paths = os.environ.get('PATH', default_paths).split(os.pathsep)
# 	found_commands = [path for path in search_paths if os.path.exists(os.path.join(path, command))]
# 
# 	return len(found_commands) > 0


import sys
from gi.repository import Gtk, Gdk
from subprocess import check_output, run
from threading import Thread
from sunflower.common import executable_exists
	def get_text(self):
		"""Return text value stored in clipboard."""
		return self.text

	def get_data(self, mime_types):
		"""Return data stored for provided types in clipboard."""
		data = None

		for mime_type in mime_types:
			if mime_type in self.data:
				data = self.data[mime_type]
				break

		return data

	def text_available(self):
		"""Check if clipboard with text is available."""
		return self.text is not None

	def data_available(self, mime_types):
		"""Check if clipboard with specified mime types is available."""
		targets_available = [target in self.data for target in mime_types]
		return any(targets_available)


class CommandProvider(Provider):
	"""Clipboard integration using command line application and piping."""

	def __init__(self):
		commands = ['xclip', 'wl-copy', 'wl-paste']

# Path: sunflower/common.py
# def executable_exists(command):
# 	"""Check if specified command exists in search path"""
# 	default_paths = os.pathsep.join(('/bin', '/usr/bin', '/usr/local/bin'))
# 	search_paths = os.environ.get('PATH', default_paths).split(os.pathsep)
# 	found_commands = [path for path in search_paths if os.path.exists(os.path.join(path, command))]
# 
# 	return len(found_commands) > 0


# Path: sunflower/clipboard.py
import sys
from gi.repository import Gtk, Gdk
from subprocess import check_output, run
from threading import Thread
from sunflower.common import executable_exists

	def get_text(self):
		"""Return text value stored in clipboard."""
		return self.text

	def get_data(self, mime_types):
		"""Return data stored for provided types in clipboard."""
		data = None

		for mime_type in mime_types:
			if mime_type in self.data:
				data = self.data[mime_type]
				break

		return data

	def text_available(self):
		"""Check if clipboard with text is available."""
		return self.text is not None

	def data_available(self, mime_types):
		"""Check if clipboard with specified mime types is available."""
		targets_available = [target in self.data for target in mime_types]
		return any(targets_available)


class CommandProvider(Provider):
	"""Clipboard integration using command line application and piping."""

	def __init__(self):
		commands = ['xclip', 'wl-copy', 'wl-paste']

		self.available_commands = tuple(filter(lambda command: executable_exists(command), commands))