Utils cleanups

- Move more stuff that belongs in netlib.human
- Move some stuff to near the only use
- Zap mitmproxy.utils.timestamp(). I see the rationale, but we used it
interchangeably with time.time() throughout the project. Since time.time()
dominates in the codebase and timestamp() is such low utility, away it goes.
This commit is contained in:
Aldo Cortesi
2016-06-07 17:12:52 +12:00
parent b180bfcf35
commit 1ffc273c94
18 changed files with 90 additions and 99 deletions

View File

@@ -5,7 +5,16 @@ import os.path
import re
from netlib import tcp, human
from . import pathod, version, utils
from . import pathod, version
def parse_anchor_spec(s):
"""
Return a tuple, or None on error.
"""
if "=" not in s:
return None
return tuple(s.split("=", 1))
def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr):
@@ -188,7 +197,7 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr):
alst = []
for i in args.anchors:
parts = utils.parse_anchor_spec(i)
parts = parse_anchor_spec(i)
if not parts:
return parser.error("Invalid anchor specification: %s" % i)
alst.append(parts)