Swap Event Module

SwapEvent class and helper functions.

class swapevent.SwapEvent(m1, m2, time)

Represents a timestamped name tag swap between two minions.

__init__(m1, m2, time)

Construct a SwapEvent.

  • m1 (str) – The ID of minion 1
  • m2 (str) – The ID of minion 2
  • time (datetime.datetime) – The time the swap occurred

TypeError – if time is not an instance of datetime.datetime


Compare two SwapEvent s according to time stamp.

If we have two SwapEvent s, a and b, a is less than b if a ‘s time stamp occurs before b ‘s time stamp.

Parameters:other (SwapEvent) – the other SwapEvent
Raises:TypeError – if other is not a SwapEvent

Return a string representation of a SwapEvent object.

>>> from datetime import datetime
>>> d = datetime(2017, 9, 11, 13, 28, 8)
>>> s = SwapEvent("3", "1", d)
>>> str(s)
'3 swapped with 1 at 2017-09-11T13:28:08'

Convert items from an iterable to SwapEvent s.

Returns an iterable that attempts to convert items yielded from iterable into SwapEvent objects and yields the results. In other words, this generator iterates through iterable, converts each item to a SwapEvent, and yields the resulting SwapEvent.

iterable should yield strings with the following format:

ID1 swapped with ID2 at TIME


Fields must be separated by a single space.

Parameters:iterable – An iterable that yields str