diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-05-27 11:18:54 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-05-27 11:19:11 +0200 |
commit | e3d390e036430b9d7cc4b93679229fe118eb583a (patch) | |
tree | 1f10a2a59c8abef4bd24c8189d14602264b20fad /netlib/utils.py | |
parent | f7b75ba8c21c66e38da81adf3b2c573b7dae87f3 (diff) | |
download | mitmproxy-e3d390e036430b9d7cc4b93679229fe118eb583a.tar.gz mitmproxy-e3d390e036430b9d7cc4b93679229fe118eb583a.tar.bz2 mitmproxy-e3d390e036430b9d7cc4b93679229fe118eb583a.zip |
cleanup code with autopep8
run the following command:
$ autopep8 -i -r -a -a .
Diffstat (limited to 'netlib/utils.py')
-rw-r--r-- | netlib/utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/netlib/utils.py b/netlib/utils.py index 7e539977..9c5404e6 100644 --- a/netlib/utils.py +++ b/netlib/utils.py @@ -68,6 +68,7 @@ def getbit(byte, offset): class BiDi: + """ A wee utility class for keeping bi-directional mappings, like field constants in protocols. Names are attributes on the object, dict-like @@ -77,6 +78,7 @@ class BiDi: assert CONST.a == 1 assert CONST.get_name(1) == "a" """ + def __init__(self, **kwargs): self.names = kwargs self.values = {} @@ -96,15 +98,15 @@ class BiDi: def pretty_size(size): suffixes = [ - ("B", 2**10), - ("kB", 2**20), - ("MB", 2**30), + ("B", 2 ** 10), + ("kB", 2 ** 20), + ("MB", 2 ** 30), ] for suf, lim in suffixes: if size >= lim: continue else: - x = round(size/float(lim/2**10), 2) + x = round(size / float(lim / 2 ** 10), 2) if x == int(x): x = int(x) return str(x) + suf |