<commit_before>import weakref

class Self(object):
	def __init__(self, wrapped):
		object.__setattr__(self, '_wrapped', weakref.ref(wrapped))
	def __getattribute__(self, name):
		object.__getattribute__(object.__getattribute__(
			self, '_wrapped')(), name)
	def __setattr__(self, name, value):
		object.__setattr__(object.__getattribute__(
			self, '_wrapped')(), name, value)
	def __delattr__(self, name):
		object.__delattr__(object.__getattribute__(
			self, '_wrapped')(), name)

class DictLike(object):
	""" Base class for a dictionary based object.
	    Think about wrappers around JSON data. """
	def __init__(self, data):
		object.__setattr__(self, 'self', Self(self))
		self.self._data = data
	def __getattr__(self, name):
		try:
			return self._data[name]
		except KeyError:
			raise AttributeError
	def __setattr__(self, name, value):
		self._data[name] = value
	def __delattr__(self, name):
		del self._data[name]
	def to_dict(self):
		return self._data
	def __repr__(self):
		return "%s(%s)" % (self.__class__.__name__, repr(self._data))

class AliasingMixin(object):
	aliases = {}
	def normalize_dict(self, data):
		_data = {}
		aliases = type(self).aliases
		for k, v in data.iteritems():
			if k in aliases:
				k = aliases[k]
			_data[k] = v<commit_msg>AliasingMixin: make normalize_dict a classmethod<commit_after>import weakref

class Self(object):
	def __init__(self, wrapped):
		object.__setattr__(self, '_wrapped', weakref.ref(wrapped))
	def __getattribute__(self, name):
		object.__getattribute__(object.__getattribute__(
			self, '_wrapped')(), name)
	def __setattr__(self, name, value):
		object.__setattr__(object.__getattribute__(
			self, '_wrapped')(), name, value)
	def __delattr__(self, name):
		object.__delattr__(object.__getattribute__(
			self, '_wrapped')(), name)

class DictLike(object):
	""" Base class for a dictionary based object.
	    Think about wrappers around JSON data. """
	def __init__(self, data):
		object.__setattr__(self, 'self', Self(self))
		self.self._data = data
	def __getattr__(self, name):
		try:
			return self._data[name]
		except KeyError:
			raise AttributeError
	def __setattr__(self, name, value):
		self._data[name] = value
	def __delattr__(self, name):
		del self._data[name]
	def to_dict(self):
		return self._data
	def __repr__(self):
		return "%s(%s)" % (self.__class__.__name__, repr(self._data))

class AliasingMixin(object):
	aliases = {}
        @classmethod
	def normalize_dict(cls, data):
		_data = {}
		aliases = cls.aliases
		for k, v in data.iteritems():
			if k in aliases:
				k = aliases[k]
			_data[k] = v
{'fraction_non_alphanumeric': 0.1335907335907336, 'fraction_numerical': 0.0, 'mean_word_length': 4.757777777777778, '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': '298149', 'n_tokens_mistral': 944, 'n_tokens_neox': 877, 'n_words': 222}