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