Label.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import functools
  2. @functools.total_ordering
  3. class Label:
  4. def __init__(self, attack_name, timestamp_start, timestamp_end, attack_note=""):
  5. """
  6. Creates a new attack label
  7. :param attack_name: The name of the associated attack
  8. :param timestamp_start: The timestamp as unix time of the first attack packet
  9. :param timestamp_end: The timestamp as unix time of the last attack packet
  10. :param attack_note: A note associated to the attack (optional)
  11. """
  12. self.attack_name = attack_name
  13. self.timestamp_start = timestamp_start
  14. self.timestamp_end = timestamp_end
  15. self.attack_note = attack_note
  16. def __eq__(self, other):
  17. return self.timestamp == other.timestamp
  18. def __lt__(self, other):
  19. return self.timestamp_start < other.timestamp_start
  20. def __gt__(self, other):
  21. return self.timestamp_start > other.timestamp_start
  22. def __str__(self):
  23. return ''.join(
  24. ['(', self.attack_name, ',', self.attack_note, ',', str(self.timestamp_start), ',', str(self.timestamp_end),
  25. ')'])