-
Notifications
You must be signed in to change notification settings - Fork 176
/
duplicate.py
25 lines (21 loc) · 765 Bytes
/
duplicate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from actions.action import Action
class DuplicateAction(Action):
"""
Defines the DuplicateAction - returns two copies of the given packet.
"""
frequency = 3
def __init__(self, environment_id=None):
Action.__init__(self, "duplicate", "out")
self.branching = True
def run(self, packet, logger):
"""
The duplicate action duplicates the given packet and returns one copy
for the left branch, and one for the right branch.
"""
logger.debug(" - Duplicating given packet %s" % str(packet))
return packet, packet.copy()
def mutate(self, environment_id=None):
"""
Swaps its left and right child
"""
self.left, self.right = self.right, self.left