<commit_before># coding=utf-8

"""This module, c_process.py, is an API for managing and interacting with a single C process."""


# Needed for running a C process and sending data to it.
from subprocess import Popen, PIPE


class CProcess(object):
	"""Represents a single running C process."""

	def __init__(self, c_executable_path, flags):
		self._c_executable_path = c_executable_path
		self._shell_string = self._c_executable_path
		if type(flags) == list:
			for f in flags:
				self._shell_string += ' ' + f + ' '
		self._c_process = None

	def _start_process(self, send_input):
		"""Starts the C process."""
		if send_input:
			self._c_process = Popen(self._shell_string, shell=True, stdin=PIPE)
		else:
			self._c_process = Popen(self._shell_string, shell=True)

	def _wait_for_process_finish(self):
		"""Lets the process finish."""
		self.c_process.wait()
		output_stdout, output_stderr = self.c_process.communicate()
		return output_stdout, output_stderr

	def run_process_and_only_get_output(self):
		"""Runs a process without providing any input."""
		self._start_process(False)
		return self._wait_for_process_finish()

	def run_process_with_input(self, data_that_is_list_of_lists):
		"""Runs a process with provided input."""
		#self.start_process(True)
		# TODO : THIS FUNCTION!!!



'''
class CProcess(object):
	"""Represents a single running C process."""<commit_msg>finance updating 81<commit_after># coding=utf-8

"""This module, c_process.py, is an API for managing and interacting with a single C process."""


# Needed for running a C process and sending data to it.
from subprocess import Popen, PIPE


class CProcess(object):
	"""Represents a single running C process."""

	def __init__(self, c_executable_path, flags):
		self._c_executable_path = c_executable_path
		self._shell_string = self._c_executable_path
		if type(flags) == list:
			for f in flags:
				self._shell_string += ' ' + f + ' '
		self._c_process = None

	def _start_process(self, send_input):
		"""Starts the C process."""
		if send_input:
			self._c_process = Popen(self._shell_string, shell=True, stdin=PIPE)
		else:
			self._c_process = Popen(self._shell_string, shell=True, stdin=PIPE)

	def _wait_for_process_finish(self):
		"""Lets the process finish."""
		self.c_process.wait()
		output_stdout, output_stderr = self.c_process.communicate()
		return output_stdout, output_stderr

	def run_process_and_only_get_output(self):
		"""Runs a process without providing any input."""
		self._start_process(False)
		return self._wait_for_process_finish()

	def run_process_with_input(self, data_that_is_list_of_lists):
		"""Runs a process with provided input."""
		#self.start_process(True)
		# TODO : THIS FUNCTION!!!



'''
class CProcess(object):
	"""Represents a single running C process."""
{'fraction_non_alphanumeric': 0.11198851399856424, 'fraction_numerical': 0.0014357501794687725, 'mean_word_length': 4.9297872340425535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7625107', 'n_tokens_mistral': 980, 'n_tokens_neox': 905, 'n_words': 248}