diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-10-01 12:32:56 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-10-03 11:45:54 +0200 |
commit | 5f8b8bf35e7a8c434310c93c13871f863f12fecc (patch) | |
tree | 1adbec32cb8b6306c254cf34b50c7a6833b3a146 | |
parent | ba842489103caba2691084a1f32f3c79f8f564d6 (diff) | |
download | mitmproxy-5f8b8bf35e7a8c434310c93c13871f863f12fecc.tar.gz mitmproxy-5f8b8bf35e7a8c434310c93c13871f863f12fecc.tar.bz2 mitmproxy-5f8b8bf35e7a8c434310c93c13871f863f12fecc.zip |
move flow.match to flowfilter.match
-rw-r--r-- | mitmproxy/flowfilter.py | 6 | ||||
-rw-r--r-- | mitmproxy/models/flow.py | 21 |
2 files changed, 8 insertions, 19 deletions
diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index a6398957..6ca74b68 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -36,6 +36,7 @@ from __future__ import absolute_import, print_function, division import re import sys import functools +import six from mitmproxy.models.http import HTTPFlow from mitmproxy.models.tcp import TCPFlow @@ -501,16 +502,15 @@ def parse(s): return None -def match(self, flow, flt): +def match(flow, flt): """ - Match a flow against a compiled filter expression. + Matches a flow against a compiled filter expression. Returns True if matched, False if not. If flt is a string, it will be compiled as a filter expression. If the expression is invalid, ValueError is raised. """ if isinstance(flt, six.string_types): - flt = parse(flt) if not flt: raise ValueError("Invalid filter expression.") diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py index f8c0b210..6fce6e20 100644 --- a/mitmproxy/models/flow.py +++ b/mitmproxy/models/flow.py @@ -189,20 +189,9 @@ class Flow(stateobject.StateObject): self.reply.commit() master.handle_accept_intercept(self) - def match(self, flt): - """ - Matches a flow against a compiled filter expression. - Returns True if matched, False if not. + def match(self, f): + import warnings + warnings.warn(".match() is deprecated, please use flowfilter.match(some_flow, some_filter) instead.", DeprecationWarning) - If flt is a string, it will be compiled as a filter expression. - If the expression is invalid, ValueError is raised. - """ - if isinstance(flt, six.string_types): - from ..flowfilter import parse - - flt = parse(flt) - if not flt: - raise ValueError("Invalid filter expression.") - if flt: - return flt(self) - return True + from mitmproxy import flowfilter + return flowfilter.match(self, f) |