Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
""" consume an observable and produce entry """
# classical create/update
try: # update entry
entry = self._roots[obs.root_idx][obs.nfhash].update(obs,
self.core_plugins,
self.user_plugins,
self.active_timeout)
if entry is not None:
if entry.expiration_id < 0: # custom expiration
self.producer.send_pyobj(entry)
del self._roots[obs.root_idx][obs.nfhash]
self.active_entries -= 1
else: # active expiration
self.producer.send_pyobj(entry)
del self._roots[obs.root_idx][obs.nfhash]
self._roots[obs.root_idx][obs.nfhash] = NFEntry(obs,
self.core_plugins,
self.user_plugins,
self.idx_generator)
self.idx_generator += 1
except KeyError: # create entry
self._roots[obs.root_idx][obs.nfhash] = NFEntry(obs,
self.core_plugins,
self.user_plugins,
self.idx_generator)
self.active_entries += 1
self.idx_generator += 1
self.active_timeout)
if entry is not None:
if entry.expiration_id < 0: # custom expiration
self.producer.send_pyobj(entry)
del self._roots[obs.root_idx][obs.nfhash]
self.active_entries -= 1
else: # active expiration
self.producer.send_pyobj(entry)
del self._roots[obs.root_idx][obs.nfhash]
self._roots[obs.root_idx][obs.nfhash] = NFEntry(obs,
self.core_plugins,
self.user_plugins,
self.idx_generator)
self.idx_generator += 1
except KeyError: # create entry
self._roots[obs.root_idx][obs.nfhash] = NFEntry(obs,
self.core_plugins,
self.user_plugins,
self.idx_generator)
self.active_entries += 1
self.idx_generator += 1