<commit_before>import os
import configparser

class config:
	# Check if config.ini exists and load/generate it
	def __init__(self, file):
		"""
		Initialize a config file object

		:param file: file name
		"""
		self.config = configparser.ConfigParser()
		self.default = True
		self.fileName = file
		if os.path.isfile(self.fileName):
			# config.ini found, load it
			self.config.read(self.fileName)
			self.default = False
		else:
			# config.ini not found, generate a default one
			self.generateDefaultConfig()
			self.default = True


	# Check if config.ini has all needed the keys
	def checkConfig(self):
		"""
		Check is the config file has all required keys

		:return: True if valid, False if not valid
		"""
		try:
			# Try to get all the required keys
			self.config.get("db","host")
			self.config.get("db","username")
			self.config.get("db","password")
			self.config.get("db","database")
			self.config.get("db","workers")

			self.config.get("redis","host")
			self.config.get("redis","port")
			self.config.get("redis","database")
			self.config.get("redis","password")

			self.config.get("server","port")
			self.config.get("server","threads")
			self.config.get("server","gzip")
			self.config.get("server","gziplevel")
			self.config.get("server","cikey")

			self.config.get("mirror","url")
			self.config.get("mirror","apikey")

			self.config.get("debug","enable")
			self.config.get("debug","packets")
			self.config.get("debug","time")

			self.config.get("sentry","enable")
			self.config.get("sentry","banchodns")
			self.config.get("sentry","ircdns")

			self.config.get("discord","enable")
			self.config.get("discord","boturl")
			self.config.get("discord","devgroup")

			self.config.get("datadog", "enable")
			self.config.get("datadog", "apikey")
			self.config.get("datadog", "appkey")

			self.config.get("irc","enable")
			self.config.get("irc","port")
			self.config.get("irc","hostname")

			self.config.get("localize","enable")
			self.config.get("localize","ipapiurl")
			return True
		except:
			return False

	def generateDefaultConfig(self):
		"""
		Write a default config file to disk

		:return:
		"""
		# Open config.ini in write mode
		f = open(self.fileName, "w")

		# Set keys to config object
		self.config.add_section("db")
		self.config.set("db", "host", "localhost")
		self.config.set("db", "username", "root")
		self.config.set("db", "password", "")
		self.config.set("db", "database", "ripple")
		self.config.set("db", "workers", "4")

		self.config.add_section("redis")
		self.config.set("redis", "host", "localhost")
		self.config.set("redis", "port", "6379")
		self.config.set("redis", "database", "0")
		self.config.set("redis", "password", "")

		self.config.add_section("server")
		self.config.set("server", "port", "5001")
		self.config.set("server", "threads", "16")
		self.config.set("server", "gzip", "1")
		self.config.set("server", "gziplevel", "6")
		self.config.set("server", "cikey", "changeme")

		self.config.add_section("mirror")
		self.config.set("mirror", "url", "http://storage.ripple.moe")
		self.config.set("mirror", "apikey", "anotherkey")

		self.config.add_section("debug")
		self.config.set("debug", "enable", "0")
		self.config.set("debug", "packets", "0")
		self.config.set("debug", "time", "0")

		self.config.add_section("sentry")
		self.config.set("sentry", "enable", "0")
		self.config.set("sentry", "banchodns", "")
		self.config.set("sentry", "ircdns", "")

		self.config.add_section("discord")
		self.config.set("discord", "enable", "0")
		self.config.set("discord", "boturl", "")
		self.config.set("discord", "devgroup", "")

		self.config.add_section("datadog")
		self.config.set("datadog", "enable")
		self.config.set("datadog", "apikey")
		self.config.set("datadog", "appkey")

		self.config.add_section("irc")
		self.config.set("irc", "enable", "1")
		self.config.set("irc", "port", "6667")
		self.config.set("irc", "hostname", "ripple")

		self.config.add_section("localize")
		self.config.set("localize", "enable", "1")
		self.config.set("localize", "ipapiurl", "http://ip.zxq.co")

		# Write ini to file and close
		self.config.write(f)<commit_msg>.BANCHO. .FIX. Fix wrong default configuration file<commit_after>import os
import configparser

class config:
	# Check if config.ini exists and load/generate it
	def __init__(self, file):
		"""
		Initialize a config file object

		:param file: file name
		"""
		self.config = configparser.ConfigParser()
		self.default = True
		self.fileName = file
		if os.path.isfile(self.fileName):
			# config.ini found, load it
			self.config.read(self.fileName)
			self.default = False
		else:
			# config.ini not found, generate a default one
			self.generateDefaultConfig()
			self.default = True


	# Check if config.ini has all needed the keys
	def checkConfig(self):
		"""
		Check is the config file has all required keys

		:return: True if valid, False if not valid
		"""
		try:
			# Try to get all the required keys
			self.config.get("db","host")
			self.config.get("db","username")
			self.config.get("db","password")
			self.config.get("db","database")
			self.config.get("db","workers")

			self.config.get("redis","host")
			self.config.get("redis","port")
			self.config.get("redis","database")
			self.config.get("redis","password")

			self.config.get("server","port")
			self.config.get("server","threads")
			self.config.get("server","gzip")
			self.config.get("server","gziplevel")
			self.config.get("server","cikey")

			self.config.get("mirror","url")
			self.config.get("mirror","apikey")

			self.config.get("debug","enable")
			self.config.get("debug","packets")
			self.config.get("debug","time")

			self.config.get("sentry","enable")
			self.config.get("sentry","banchodns")
			self.config.get("sentry","ircdns")

			self.config.get("discord","enable")
			self.config.get("discord","boturl")
			self.config.get("discord","devgroup")

			self.config.get("datadog", "enable")
			self.config.get("datadog", "apikey")
			self.config.get("datadog", "appkey")

			self.config.get("irc","enable")
			self.config.get("irc","port")
			self.config.get("irc","hostname")

			self.config.get("localize","enable")
			self.config.get("localize","ipapiurl")
			return True
		except:
			return False

	def generateDefaultConfig(self):
		"""
		Write a default config file to disk

		:return:
		"""
		# Open config.ini in write mode
		f = open(self.fileName, "w")

		# Set keys to config object
		self.config.add_section("db")
		self.config.set("db", "host", "localhost")
		self.config.set("db", "username", "root")
		self.config.set("db", "password", "")
		self.config.set("db", "database", "ripple")
		self.config.set("db", "workers", "4")

		self.config.add_section("redis")
		self.config.set("redis", "host", "localhost")
		self.config.set("redis", "port", "6379")
		self.config.set("redis", "database", "0")
		self.config.set("redis", "password", "")

		self.config.add_section("server")
		self.config.set("server", "port", "5001")
		self.config.set("server", "threads", "16")
		self.config.set("server", "gzip", "1")
		self.config.set("server", "gziplevel", "6")
		self.config.set("server", "cikey", "changeme")

		self.config.add_section("mirror")
		self.config.set("mirror", "url", "http://storage.ripple.moe")
		self.config.set("mirror", "apikey", "anotherkey")

		self.config.add_section("debug")
		self.config.set("debug", "enable", "0")
		self.config.set("debug", "packets", "0")
		self.config.set("debug", "time", "0")

		self.config.add_section("sentry")
		self.config.set("sentry", "enable", "0")
		self.config.set("sentry", "banchodns", "")
		self.config.set("sentry", "ircdns", "")

		self.config.add_section("discord")
		self.config.set("discord", "enable", "0")
		self.config.set("discord", "boturl", "")
		self.config.set("discord", "devgroup", "")

		self.config.add_section("datadog")
		self.config.set("datadog", "enable", "0")
		self.config.set("datadog", "apikey", "")
		self.config.set("datadog", "appkey", "")

		self.config.add_section("irc")
		self.config.set("irc", "enable", "1")
		self.config.set("irc", "port", "6667")
		self.config.set("irc", "hostname", "ripple")

		self.config.add_section("localize")
		self.config.set("localize", "enable", "1")
		self.config.set("localize", "ipapiurl", "http://ip.zxq.co")

		# Write ini to file and close
		self.config.write(f)
{'fraction_non_alphanumeric': 0.20522343356894693, 'fraction_numerical': 0.006109979633401222, 'mean_word_length': 4.470511140235911, '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': '7185072', 'n_tokens_mistral': 3314, 'n_tokens_neox': 2933, 'n_words': 520}