mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
fix prospector code smells
This commit is contained in:
parent
ce0e2b12b4
commit
bfc889d29a
@ -1,5 +1,8 @@
|
||||
max-line-length: 120
|
||||
pylint:
|
||||
options:
|
||||
dummy-variables-rgx: _$|.+_$|dummy_.+
|
||||
|
||||
disable:
|
||||
- missing-docstring
|
||||
- protected-access
|
||||
|
@ -10,6 +10,7 @@ logging.basicConfig(level="DEBUG")
|
||||
EXAMPLE_HOST = "example.com"
|
||||
EXAMPLE_WEBSOCKET_KEY = "examplekey"
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
|
||||
def make_app(noapi, debug):
|
||||
app = Flask(__name__)
|
||||
@ -145,24 +146,24 @@ def make_app(noapi, debug):
|
||||
|
||||
s = cStringIO.StringIO()
|
||||
|
||||
set = copy.copy(app.config["pathod"].settings)
|
||||
set.request_host = EXAMPLE_HOST
|
||||
set.websocket_key = EXAMPLE_WEBSOCKET_KEY
|
||||
settings = copy.copy(app.config["pathod"].settings)
|
||||
settings.request_host = EXAMPLE_HOST
|
||||
settings.websocket_key = EXAMPLE_WEBSOCKET_KEY
|
||||
|
||||
safe = r.preview_safe()
|
||||
err, safe = app.config["pathod"].check_policy(
|
||||
safe,
|
||||
set
|
||||
settings
|
||||
)
|
||||
if err:
|
||||
args["error"] = err
|
||||
return render(template, False, **args)
|
||||
if is_request:
|
||||
set.request_host = EXAMPLE_HOST
|
||||
language.serve(safe, s, set)
|
||||
settings.request_host = EXAMPLE_HOST
|
||||
language.serve(safe, s, settings)
|
||||
else:
|
||||
set.websocket_key = EXAMPLE_WEBSOCKET_KEY
|
||||
language.serve(safe, s, set)
|
||||
settings.websocket_key = EXAMPLE_WEBSOCKET_KEY
|
||||
language.serve(safe, s, settings)
|
||||
|
||||
args["output"] = utils.escape_unprintables(s.getvalue())
|
||||
return render(template, False, **args)
|
||||
|
@ -13,7 +13,7 @@ assert Settings # prevent pyflakes from messing with this
|
||||
def expand(msg):
|
||||
times = getattr(msg, "times", None)
|
||||
if times:
|
||||
for j in xrange(int(times.value)):
|
||||
for j_ in xrange(int(times.value)):
|
||||
yield msg.strike_token("times")
|
||||
else:
|
||||
yield msg
|
||||
|
@ -71,7 +71,7 @@ class PauseAt(_Action):
|
||||
def intermediate(self, settings):
|
||||
return (self.offset, "pause", self.seconds)
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ class DisconnectAt(_Action):
|
||||
def intermediate(self, settings):
|
||||
return (self.offset, "disconnect")
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ class Token(object):
|
||||
"""
|
||||
return self.__class__.__name__.lower()
|
||||
|
||||
def resolve(self, settings, msg):
|
||||
def resolve(self, settings_, msg_):
|
||||
"""
|
||||
Resolves this token to ready it for transmission. This means that
|
||||
the calculated offsets of actions are fixed.
|
||||
@ -104,10 +104,10 @@ class _TokValueLiteral(Token):
|
||||
def __init__(self, val):
|
||||
self.val = val.decode("string_escape")
|
||||
|
||||
def get_generator(self, settings):
|
||||
def get_generator(self, settings_):
|
||||
return self.val
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ class TokValueGenerate(Token):
|
||||
def bytes(self):
|
||||
return self.usize * utils.SIZE_UNITS[self.unit]
|
||||
|
||||
def get_generator(self, settings):
|
||||
def get_generator(self, settings_):
|
||||
return generators.RandomGenerator(self.datatype, self.bytes())
|
||||
|
||||
def freeze(self, settings):
|
||||
@ -194,7 +194,7 @@ class TokValueFile(Token):
|
||||
e = e + v_naked_literal
|
||||
return e.setParseAction(lambda x: cls(*x))
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
def get_generator(self, settings):
|
||||
@ -310,7 +310,7 @@ class CaselessLiteral(_Component):
|
||||
def spec(self):
|
||||
return self.TOK
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
|
||||
@ -390,7 +390,7 @@ class Integer(_Component):
|
||||
def spec(self):
|
||||
return "%s%s" % (self.preamble, self.value)
|
||||
|
||||
def freeze(self, settings):
|
||||
def freeze(self, settings_):
|
||||
return self
|
||||
|
||||
|
||||
@ -476,7 +476,7 @@ class Boolean(_Component):
|
||||
e = pp.Optional(pp.Literal("-"), default=True)
|
||||
e += pp.Literal(cls.name).suppress()
|
||||
|
||||
def parse(s, loc, toks):
|
||||
def parse(s_, loc_, toks):
|
||||
val = True
|
||||
if toks[0] == "-":
|
||||
val = False
|
||||
|
@ -1,5 +1,5 @@
|
||||
import pyparsing as pp
|
||||
from . import base, actions, message
|
||||
from . import base, message
|
||||
|
||||
"""
|
||||
Normal HTTP requests:
|
||||
|
@ -123,7 +123,7 @@ class WebsocketFrameReader(threading.Thread):
|
||||
while True:
|
||||
if self.ws_read_limit == 0:
|
||||
return
|
||||
r, _, x = select.select([self.rfile], [], [], 0.05)
|
||||
r, _, _ = select.select([self.rfile], [], [], 0.05)
|
||||
delta = time.time() - starttime
|
||||
if not r and self.timeout and delta > self.timeout:
|
||||
return
|
||||
@ -501,11 +501,11 @@ def main(args): # pragma: nocover
|
||||
if ret and args.oneshot:
|
||||
return
|
||||
# We consume the queue when we can, so it doesn't build up.
|
||||
for i in p.wait(timeout=0, finish=False):
|
||||
for i_ in p.wait(timeout=0, finish=False):
|
||||
pass
|
||||
except (http.HttpError, tcp.NetLibError) as v:
|
||||
break
|
||||
for i in p.wait(timeout=0.01, finish=True):
|
||||
for i_ in p.wait(timeout=0.01, finish=True):
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
@ -3,9 +3,8 @@ import sys
|
||||
import argparse
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
from netlib import http_uastrings
|
||||
from . import pathoc, pathod, version, utils, language
|
||||
from . import pathoc, version, utils, language
|
||||
|
||||
|
||||
def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr):
|
||||
|
@ -171,7 +171,7 @@ class PathodHandler(tcp.BaseHandler):
|
||||
self.wfile.flush()
|
||||
if not self.server.ssloptions.not_after_connect:
|
||||
try:
|
||||
cert, key, chain_file = self.server.ssloptions.get_cert(
|
||||
cert, key, chain_file_ = self.server.ssloptions.get_cert(
|
||||
connect[0]
|
||||
)
|
||||
self.convert_to_ssl(
|
||||
@ -576,9 +576,9 @@ class Pathod(tcp.TCPServer):
|
||||
with lock:
|
||||
self.log = []
|
||||
|
||||
def log_by_id(self, id):
|
||||
def log_by_id(self, identifier):
|
||||
for i in self.log:
|
||||
if i["id"] == id:
|
||||
if i["id"] == identifier:
|
||||
return i
|
||||
|
||||
def get_log(self):
|
||||
|
@ -4,10 +4,10 @@ import argparse
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
from . import pathod, version, utils, language
|
||||
from . import pathod, version, utils
|
||||
|
||||
|
||||
def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
|
||||
def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr):
|
||||
parser = argparse.ArgumentParser(
|
||||
description='A pathological HTTP/S daemon.'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user