<commit_before>import os
import re
import yaml
import logging
import shutil

from cardice import templates


LOGGING_FORMAT = "[%(cluster)s] %(message)s"


TEMPLATE_FOLDER = templates.__path__[0]


class Configurator(object):
	"""Manage the cardice configuration folder"""

	default_cluster_filename = "default_cluster"

	valid_cluster_name = re.compile(r"^[\w_-]+$")

	default_cluster = None

	def __init__(self, options):
		# Configure logging
		level = getattr(logging, options.log_level.upper())
		logging.basicConfig(level=level, format=LOGGING_FORMAT)

	    # Setup config folder
		self.options = options
		config_folder = os.path.abspath(os.path.expanduser(
			options.cardice_folder))
		if not os.path.exists(config_folder):
			os.makedirs(config_folder)
			shutil.copyfile(
				os.path.join(TEMPLATE_FOLDER, 'default_profiles.yaml'),
				os.path.join(config_folder, 'profiles.yaml'))

		self.config_folder = config_folder
		self.log = self.get_logger()
		self.log.debug("initialized configuration in: %s", config_folder)

	def get_cluster_folder(self):
		"""Fetch the configuration folder path for the active cluster"""
		cluster_name = self.get_active_cluster()<commit_msg>Initialize a default cluster config<commit_after>import os
import re
import yaml
import logging
import shutil

from cardice import templates


LOGGING_FORMAT = "[%(cluster)s] %(message)s"


TEMPLATE_FOLDER = templates.__path__[0]


class Configurator(object):
	"""Manage the cardice configuration folder"""

	default_cluster_filename = "default_cluster"

	valid_cluster_name = re.compile(r"^[\w_-]+$")

	default_cluster = None

	def __init__(self, options):
		# Configure logging
		level = getattr(logging, options.log_level.upper())
		logging.basicConfig(level=level, format=LOGGING_FORMAT)

	    # Setup config folder
		self.options = options
		config_folder = os.path.abspath(os.path.expanduser(
			options.cardice_folder))

		first_time = False
		if not os.path.exists(config_folder):
			os.makedirs(config_folder)
			shutil.copyfile(
				os.path.join(TEMPLATE_FOLDER, 'default_profiles.yaml'),
				os.path.join(config_folder, 'profiles.yaml'))
			first_time = True

		self.config_folder = config_folder
		self.log = self.get_logger()
		
		if first_time:
			self.log.debug("initialized configuration in: %s", config_folder)
			self.init_cluster("default")
		else:
			self.log.debug("reading configuration from: %s", config_folder)


	def get_cluster_folder(self):
		"""Fetch the configuration folder path for the active cluster"""
		cluster_name = self.get_active_cluster()
{'fraction_non_alphanumeric': 0.1109375, 'fraction_numerical': 0.00078125, 'mean_word_length': 5.15625, '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': '2833538', 'n_tokens_mistral': 905, 'n_tokens_neox': 819, 'n_words': 178}