<commit_before>import gobject
import gtk
import dbus

class Buddy(gobject.GObject):

	__gsignals__ = {
		'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([])),
		'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'joined-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'left-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'property-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT]))
	}

	_PRESENCE_SERVICE = "org.laptop.Presence"
	_BUDDY_DBUS_INTERFACE = "org.laptop.Presence.Buddy"

	def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
		gobject.GObject.__init__(self)
		self._object_path = object_path
		self._ps_new_object = new_obj_cb
		self._ps_del_object = del_obj_cb
		self._properties = {}
		bobj = bus.get_object(self._PRESENCE_SERVICE, object_path)
		self._buddy = dbus.Interface(bobj, self._BUDDY_DBUS_INTERFACE)
		self._buddy.connect_to_signal('IconChanged', self._icon_changed_cb)
		self._buddy.connect_to_signal('ServiceAppeared', self._service_appeared_cb)
		self._buddy.connect_to_signal('ServiceDisappeared', self._service_disappeared_cb)
		self._buddy.connect_to_signal('JoinedActivity', self._joined_activity_cb)
		self._buddy.connect_to_signal('LeftActivity', self._left_activity_cb)
		self._buddy.connect_to_signal('PropertyChanged', self._property_changed_cb)
		self._properties = self._buddy.getProperties()

	def object_path(self):
		return self._object_path

	def _emit_icon_changed_signal(self):
		self.emit('icon-changed')
		return False

	def _icon_changed_cb(self):
		gobject.idle_add(self._emit_icon_changed_signal)

	def _emit_service_appeared_signal(self, object_path):
		self.emit('service-appeared', self._ps_new_object(object_path))
		return False

	def _service_appeared_cb(self, object_path):
		gobject.idle_add(self._emit_service_appeared_signal, object_path)

	def _emit_service_disappeared_signal(self, object_path):
		self.emit('service-disappeared', self._ps_new_object(object_path))
		return False

	def _service_disappeared_cb(self, object_path):
		gobject.idle_add(self._emit_service_disappeared_signal, object_path)

	def _emit_joined_activity_signal(self, object_path):
		self.emit('joined-activity', self._ps_new_object(object_path))
		return False

	def _joined_activity_cb(self, object_path):
		gobject.idle_add(self._emit_joined_activity_signal, object_path)

	def _emit_left_activity_signal(self, object_path):
		self.emit('left-activity', self._ps_new_object(object_path))
		return False

	def _left_activity_cb(self, object_path):
		gobject.idle_add(self._emit_left_activity_signal, object_path)

	def _handle_property_changed_signal(self, prop_list):
		self._properties = self._buddy.getProperties()
		self.emit('property-changed', prop_list)
		return False

	def _property_changed_cb(self, prop_list):
		gobject.idle_add(self._handle_property_changed_signal, prop_list)

	def get_name(self):
		return self._properties['name']

	def get_ip4_address(self):
		return self._properties['ip4_address']

	def is_owner(self):
		return self._properties['owner']

	def get_color(self):<commit_msg>Ensure properties will always be an empty dict<commit_after>import gobject
import gtk
import dbus

class Buddy(gobject.GObject):

	__gsignals__ = {
		'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([])),
		'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'joined-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'left-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT])),
		'property-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
						 ([gobject.TYPE_PYOBJECT]))
	}

	_PRESENCE_SERVICE = "org.laptop.Presence"
	_BUDDY_DBUS_INTERFACE = "org.laptop.Presence.Buddy"

	def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
		gobject.GObject.__init__(self)
		self._object_path = object_path
		self._ps_new_object = new_obj_cb
		self._ps_del_object = del_obj_cb
		self._properties = {}
		bobj = bus.get_object(self._PRESENCE_SERVICE, object_path)
		self._buddy = dbus.Interface(bobj, self._BUDDY_DBUS_INTERFACE)
		self._buddy.connect_to_signal('IconChanged', self._icon_changed_cb)
		self._buddy.connect_to_signal('ServiceAppeared', self._service_appeared_cb)
		self._buddy.connect_to_signal('ServiceDisappeared', self._service_disappeared_cb)
		self._buddy.connect_to_signal('JoinedActivity', self._joined_activity_cb)
		self._buddy.connect_to_signal('LeftActivity', self._left_activity_cb)
		self._buddy.connect_to_signal('PropertyChanged', self._property_changed_cb)
		self._properties = self._get_properties_helper()

	def _get_properties_helper(self):
		props = self._buddy.getProperties()
		if not props:
			return {}
		return props

	def object_path(self):
		return self._object_path

	def _emit_icon_changed_signal(self):
		self.emit('icon-changed')
		return False

	def _icon_changed_cb(self):
		gobject.idle_add(self._emit_icon_changed_signal)

	def _emit_service_appeared_signal(self, object_path):
		self.emit('service-appeared', self._ps_new_object(object_path))
		return False

	def _service_appeared_cb(self, object_path):
		gobject.idle_add(self._emit_service_appeared_signal, object_path)

	def _emit_service_disappeared_signal(self, object_path):
		self.emit('service-disappeared', self._ps_new_object(object_path))
		return False

	def _service_disappeared_cb(self, object_path):
		gobject.idle_add(self._emit_service_disappeared_signal, object_path)

	def _emit_joined_activity_signal(self, object_path):
		self.emit('joined-activity', self._ps_new_object(object_path))
		return False

	def _joined_activity_cb(self, object_path):
		gobject.idle_add(self._emit_joined_activity_signal, object_path)

	def _emit_left_activity_signal(self, object_path):
		self.emit('left-activity', self._ps_new_object(object_path))
		return False

	def _left_activity_cb(self, object_path):
		gobject.idle_add(self._emit_left_activity_signal, object_path)

	def _handle_property_changed_signal(self, prop_list):
		self._properties = self._get_properties_helper()
		self.emit('property-changed', prop_list)
		return False

	def _property_changed_cb(self, prop_list):
		gobject.idle_add(self._handle_property_changed_signal, prop_list)

	def get_name(self):
		return self._properties['name']

	def get_ip4_address(self):
		return self._properties['ip4_address']

	def is_owner(self):
		return self._properties['owner']

	def get_color(self):
{'fraction_non_alphanumeric': 0.1082376870550632, 'fraction_numerical': 0.0005811419439198024, 'mean_word_length': 6.5731573157315735, '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': '3676118', 'n_tokens_mistral': 2643, 'n_tokens_neox': 2423, 'n_words': 332}