Compare two commands/events, and possibly update placeholders.
(a: PlaybookEntry, b: PlaybookEntry)
| 26 | |
| 27 | |
| 28 | def _eq(a: PlaybookEntry, b: PlaybookEntry) -> bool: |
| 29 | """Compare two commands/events, and possibly update placeholders.""" |
| 30 | if type(a) is not type(b): |
| 31 | return False |
| 32 | |
| 33 | a_dict = a.__dict__ |
| 34 | b_dict = b.__dict__ |
| 35 | # we can assume a.keys() == b.keys() |
| 36 | for k in a_dict: |
| 37 | if k == "blocking": |
| 38 | continue |
| 39 | x = a_dict[k] |
| 40 | y = b_dict[k] |
| 41 | |
| 42 | # if there's a placeholder, make it x. |
| 43 | if isinstance(y, _Placeholder): |
| 44 | x, y = y, x |
| 45 | if isinstance(x, _Placeholder): |
| 46 | try: |
| 47 | x = x.setdefault(y) |
| 48 | except TypeError as e: |
| 49 | raise TypeError( |
| 50 | f"Placeholder type error for {type(a).__name__}.{k}: {e}" |
| 51 | ) |
| 52 | if x != y: |
| 53 | return False |
| 54 | |
| 55 | return True |
| 56 | |
| 57 | |
| 58 | def eq( |