<commit_before>import datetime
from forgeLandWall.dbConnManage import dbConnManage

from forgeLandWall.settings import globalVars


__author__ = 'Jesse'

# Yes, I know we're all adults here, but I don't like getting suggestions for methods I don't need


class messageModel(dbConnManage):
	# Creates record handle OR reads record from db
	"""Represents a SINGLE record from the table, we manipulate the objects, rather then SQL"""

	def __init__(self, index=None, message=None):


		if index is None and message is None:
			self.__index = None

		if message is not None and index is None:
			self.__lookupRecordFromMessage(message)
		if index is not None and message is None:
			# Index should still be used for edits and delete though
			self.__index = index
			self.__lookupRecordFromIndex()
			if globalVars.debugMode: print("Record Found")

	def message(self, message=None):
		"""Gets message from object, or writes message to DB"""
		if message is None:
			return self.__messageTxt
		else:
			self.__messageTxt = message
			self.__saveRecord()

	def getTimestamp(self):
		return self.__timestamp

	def __lookupRecordFromMessage(self, searchStr):
		"""Looks up ONLY the FIRST record that matches the search"""

		dbConn, dbcursor = self.dbConnect()
		if globalVars.debugMode: print("Searching for: " + searchStr)
		try:
			sqlStr = 'SELECT * FROM messages WHERE message LIKE"%' + searchStr + '%"'
			dbcursor.execute(sqlStr)
			record = dbcursor.fetchone()
			self.__messageTxt = record[0]
			self.__timestamp = record[1]
			self.__index = record[2]
			if globalVars.debugMode: print("Record Found: " + searchStr)
		except TypeError:
			# FIXME Add better exception, no Pokemon exceptions!
			self.__messageTxt = "CANNOT FIND MESSAGE: " + searchStr
			self.__timestamp = ""
			self.__index = ""
			if globalVars.debugMode: print("Record Not Found")
		self.dbClose(dbConn)<commit_msg>Removed lookup record via text (it can return the wrong message if it gets an early match)<commit_after>import datetime
from forgeLandWall.dbConnManage import dbConnManage

from forgeLandWall.settings import globalVars


__author__ = 'Jesse'

# Yes, I know we're all adults here, but I don't like getting suggestions for methods I don't need


class messageModel(dbConnManage):
	# Creates record handle OR reads record from db
	"""Represents a SINGLE record from the table, we manipulate the objects, rather then SQL"""

	def __init__(self, index=None, message=None):

		if index is None and message is None:
			self.__index = None

		if index is not None and message is None:
			# Index should still be used for edits and delete though
			self.__index = index
			self.__lookupRecordFromIndex()
			if globalVars.debugMode: print("Record Found")

	def message(self, message=None):
		"""Gets message from object, or writes message to DB"""
		if message is None:
			return self.__messageTxt
		else:
			self.__messageTxt = message
			self.__saveRecord()

	def getTimestamp(self):
		return self.__timestamp
{'fraction_non_alphanumeric': 0.08099062918340026, 'fraction_numerical': 0.001004016064257028, 'mean_word_length': 4.318505338078292, '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': '3675059', 'n_tokens_mistral': 955, 'n_tokens_neox': 853, 'n_words': 332}