diff --git a/ipaacalib/python/src/ipaaca/buffer.py b/ipaacalib/python/src/ipaaca/buffer.py index f4e0789a769a9b91c524ae005b12360ab025ff78..12a19bc33324ec0b9ac5b53f58fe995d00b5980a 100644 --- a/ipaacalib/python/src/ipaaca/buffer.py +++ b/ipaacalib/python/src/ipaaca/buffer.py @@ -4,7 +4,7 @@ # "Incremental Processing Architecture # for Artificial Conversational Agents". # -# Copyright (c) 2009-2015 Social Cognitive Systems Group +# Copyright (c) 2009-2022 Social Cognitive Systems Group # CITEC, Bielefeld University # # http://opensource.cit-ec.de/projects/ipaaca/ @@ -171,6 +171,12 @@ class Buffer(object): return FrozenIUStore(original_iu_store = self._iu_store) iu_store = property(fget=_get_frozen_iu_store, doc='Copy-on-read version of the internal IU store') + def _get_channel(self): + return self._channel + channel = property( + fget=_get_channel, + doc='The IPAACA channel the buffer is connected to.') + def register_handler(self, handler_function, for_event_types=None, for_categories=None): """Register a new IU event handler function. @@ -307,7 +313,7 @@ class InputBuffer(Buffer): event -- a converted RSB event ''' type_ = type(event.data) - if type_ is ipaaca.iu.RemotePushIU: + if type_ == ipaaca.iu.RemotePushIU: # a new IU if event.data.uid not in self._iu_store: self._iu_store[event.data.uid] = event.data @@ -320,7 +326,7 @@ class InputBuffer(Buffer): # done via the resend request mechanism). self._iu_store[event.data.uid] = event.data event.data.buffer = self - elif type_ is ipaaca.iu.RemoteMessage: + elif type_ == ipaaca.iu.RemoteMessage: # a new Message, an ephemeral IU that is removed after calling handlers self._iu_store[ event.data.uid ] = event.data event.data.buffer = self @@ -329,7 +335,7 @@ class InputBuffer(Buffer): else: if event.data.uid not in self._iu_store: if (self._resend_active and - not type_ is ipaaca.ipaaca_pb2.IURetraction): + not type_ == ipaaca.ipaaca_pb2.IURetraction): # send resend request to remote server, IURetraction is ignored try: self._request_remote_resend(event) @@ -340,7 +346,7 @@ class InputBuffer(Buffer): LOGGER.warning("Received an update for an IU which we did not receive before.") return # an update to an existing IU - if type_ is ipaaca.ipaaca_pb2.IURetraction: + if type_ == ipaaca.ipaaca_pb2.IURetraction: # IU retraction (cannot be triggered remotely) iu = self._iu_store[event.data.uid] iu._revision = event.data.revision @@ -351,18 +357,18 @@ class InputBuffer(Buffer): # Notify only for remotely triggered events; # Discard updates that originate from this buffer return - if type_ is ipaaca.ipaaca_pb2.IUCommission: + if type_ == ipaaca.ipaaca_pb2.IUCommission: # IU commit iu = self._iu_store[event.data.uid] iu._apply_commission() iu._revision = event.data.revision self.call_iu_event_handlers(event.data.uid, local=False, event_type=ipaaca.iu.IUEventType.COMMITTED, category=iu.category) - elif type_ is ipaaca.converter.IUPayloadUpdate: + elif type_ == ipaaca.converter.IUPayloadUpdate: # IU payload update iu = self._iu_store[event.data.uid] iu._apply_update(event.data) self.call_iu_event_handlers(event.data.uid, local=False, event_type=ipaaca.iu.IUEventType.UPDATED, category=iu.category) - elif type_ is ipaaca.converter.IULinkUpdate: + elif type_ == ipaaca.converter.IULinkUpdate: # IU link update iu = self._iu_store[event.data.uid] iu._apply_link_update(event.data) @@ -509,7 +515,7 @@ class OutputBuffer(Buffer): return 0 iu = self._iu_store[iu_resend_request_pack.uid] with iu.revision_lock: - if iu_resend_request_pack.hidden_scope_name is not None and iu_resend_request_pack.hidden_scope_name is not '': + if iu_resend_request_pack.hidden_scope_name is not None and iu_resend_request_pack.hidden_scope_name != '': informer = self._get_informer(iu_resend_request_pack.hidden_scope_name) informer.publishData(iu) return iu.revision diff --git a/ipaacalib/python/src/ipaaca/converter.py b/ipaacalib/python/src/ipaaca/converter.py index 11333a6b28f5d1d6a6b7669ece5edf654d693d31..17461431a7edf541841a73abb1015ddbf70c37b5 100644 --- a/ipaacalib/python/src/ipaaca/converter.py +++ b/ipaacalib/python/src/ipaaca/converter.py @@ -4,7 +4,7 @@ # "Incremental Processing Architecture # for Artificial Conversational Agents". # -# Copyright (c) 2009-2014 Social Cognitive Systems Group +# Copyright (c) 2009-2022 Social Cognitive Systems Group # CITEC, Bielefeld University # # http://opensource.cit-ec.de/projects/ipaaca/ @@ -274,7 +274,7 @@ class IUConverter(ConverterBase): read_only = pbo.read_only, owner_name = pbo.owner_name, category = pbo.category, - payload_type = 'str' if pbo.payload_type is 'MAP' else pbo.payload_type, + payload_type = 'str' if pbo.payload_type == 'MAP' else pbo.payload_type, committed = pbo.committed, payload=_payload, links=_links)