mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
improve command repr
This commit is contained in:
parent
c4824f941d
commit
2a68029b21
@ -26,7 +26,9 @@ class Command:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"{type(self).__name__}({repr(self.__dict__)})"
|
x = self.__dict__.copy()
|
||||||
|
x.pop("blocking", None)
|
||||||
|
return f"{type(self).__name__}({repr(x)})"
|
||||||
|
|
||||||
|
|
||||||
class ConnectionCommand(Command):
|
class ConnectionCommand(Command):
|
||||||
|
@ -27,8 +27,8 @@ class Layer(metaclass=ABCMeta):
|
|||||||
self._paused = None
|
self._paused = None
|
||||||
self._paused_event_queue: typing.Deque[events.Event] = collections.deque()
|
self._paused_event_queue: typing.Deque[events.Event] = collections.deque()
|
||||||
|
|
||||||
def _debug(self, x):
|
def _debug(self, *args):
|
||||||
pass # print(x)
|
pass # print(*args)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def _handle_event(self, event: Event) -> commands.TCommandGenerator:
|
def _handle_event(self, event: Event) -> commands.TCommandGenerator:
|
||||||
|
@ -100,8 +100,8 @@ class playbook:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if isinstance(x, events.CommandReply):
|
if isinstance(x, events.CommandReply):
|
||||||
if isinstance(x.command, int) and 0 <= i + x.command < len(self.actual):
|
if isinstance(x.command, int) and abs(x.command) < len(self.actual):
|
||||||
x.command = self.actual[i + x.command]
|
x.command = self.actual[x.command]
|
||||||
|
|
||||||
self.actual.append(x)
|
self.actual.append(x)
|
||||||
self.actual.extend(
|
self.actual.extend(
|
||||||
@ -116,9 +116,7 @@ class playbook:
|
|||||||
if not success:
|
if not success:
|
||||||
def _str(x):
|
def _str(x):
|
||||||
# add arrows to diff
|
# add arrows to diff
|
||||||
ret = f"{'>' if isinstance(x, events.Event) else '<'} {x}"
|
return f"{'>' if isinstance(x, events.Event) else '<'} {x}"
|
||||||
# remove "blocking" attr which is also ignored during equality checks.
|
|
||||||
return re.sub(r", 'blocking': <.+?>", "", ret)
|
|
||||||
|
|
||||||
diff = difflib.ndiff(
|
diff = difflib.ndiff(
|
||||||
[_str(x) for x in self.playbook],
|
[_str(x) for x in self.playbook],
|
||||||
|
Loading…
Reference in New Issue
Block a user