<commit_before>import collections

from stores import valuestore


class ParamStore(valuestore.ValueStore):
	# noinspection PyProtectedMember
	def __init__(self, name, dp=None, locname=''):
		super(ParamStore, self).__init__(name)
		self.localname = locname if locname != '' else name
		self.children = collections.OrderedDict()
		self.defaultparent = dp
		if dp is not None:
			dp._MakeChild(self, self.localname)

	def SetVal(self, name, val, modifier=None):
		if self.GetVal(name, failok=True) != val:
			super(ParamStore, self).SetVal(name, val, modifier)

	def GetVal(self, name, failok=False):
		v = super(ParamStore, self).GetVal(name, failok=(self.defaultparent is not None) or failok)
		if v is None and self.defaultparent is not None:
			return self.defaultparent.GetVal(name, failok)
		else:
			return v

	def _MakeChild(self, child, nm):
		self.children[nm] = child

	# noinspection PyProtectedMember
	def ReParent(self, newparent):
		del self.defaultparent.children[self.localname]
		newparent.userstore._MakeChild(self, self.localname)<commit_msg>Allow . notation attribute access for screen params<commit_after>import collections

from stores import valuestore


class ParamStore(valuestore.ValueStore):
	# noinspection PyProtectedMember
	def __init__(self, name, dp=None, locname=''):
		super(ParamStore, self).__init__(name)
		self.localname = locname if locname != '' else name
		self.children = collections.OrderedDict()
		self.defaultparent = dp
		if dp is not None:
			dp._MakeChild(self, self.localname)

	def SetVal(self, name, val, modifier=None):
		if self.GetVal(name, failok=True) != val:
			super(ParamStore, self).SetVal(name, val, modifier)

	def GetVal(self, name, failok=False):
		v = super(ParamStore, self).GetVal(name, failok=(self.defaultparent is not None) or failok)
		if v is None and self.defaultparent is not None:
			return self.defaultparent.GetVal(name, failok)
		else:
			return v

	def _MakeChild(self, child, nm):
		self.children[nm] = child

	# noinspection PyProtectedMember
	def ReParent(self, newparent):
		del self.defaultparent.children[self.localname]
		newparent.userstore._MakeChild(self, self.localname)

	# def __setattr__(self, key, value):  todo this doesn't work as is - causes a recursion when GetVal is called via getattr
	#	if key in self.vars:
	#		self.SetVal(key, value)
	#	else:
	#		object.__setattr__(self, key, value)

	def __getattr__(self, key):
		return self.GetVal(key)
{'fraction_non_alphanumeric': 0.10892710892710893, 'fraction_numerical': 0.0, 'mean_word_length': 4.973105134474328, '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': '4186652', 'n_tokens_mistral': 861, 'n_tokens_neox': 801, 'n_words': 219}