3
0

Label.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import functools
  2. @functools.total_ordering
  3. class Label:
  4. def __init__(self, attack_name, timestamp_start, timestamp_end, seed, parameters, 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 parameters: The list of parameters used to run the attack
  11. :param attack_note: A note associated to the attack (optional)
  12. """
  13. self.attack_name = attack_name
  14. self.timestamp_start = timestamp_start
  15. self.timestamp_end = timestamp_end
  16. self.seed = seed
  17. self.attack_note = attack_note
  18. self.parameters = parameters
  19. def __eq__(self, other):
  20. return self.timestamp_start == other.timestamp_start
  21. def __lt__(self, other):
  22. return self.timestamp_start < other.timestamp_start
  23. def __gt__(self, other):
  24. return self.timestamp_start > other.timestamp_start
  25. def __str__(self):
  26. return ''.join(
  27. ['(', self.attack_name, ',', self.attack_note, ',', str(self.timestamp_start), ',', str(self.timestamp_end),
  28. ')'])