aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/stateobject.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-09-17 09:54:17 +1200
committerAldo Cortesi <aldo@nullcube.com>2014-09-17 09:54:17 +1200
commitb9531ac89ba70d8404444d4e2b86b94153a783c9 (patch)
tree6c2d970ec393509a7f195d4eabc1d35d8ff946af /libmproxy/stateobject.py
parentf7da58ca9b8b3dc33f5a9b57999b07f99db5bc63 (diff)
downloadmitmproxy-b9531ac89ba70d8404444d4e2b86b94153a783c9.tar.gz
mitmproxy-b9531ac89ba70d8404444d4e2b86b94153a783c9.tar.bz2
mitmproxy-b9531ac89ba70d8404444d4e2b86b94153a783c9.zip
Whitespace & formatting
Diffstat (limited to 'libmproxy/stateobject.py')
-rw-r--r--libmproxy/stateobject.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/libmproxy/stateobject.py b/libmproxy/stateobject.py
index 6fb73c24..9e9d6088 100644
--- a/libmproxy/stateobject.py
+++ b/libmproxy/stateobject.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+
class StateObject(object):
def _get_state(self):
raise NotImplementedError # pragma: nocover
@@ -18,7 +19,8 @@ class StateObject(object):
def __eq__(self, other):
try:
return self._get_state() == other._get_state()
- except AttributeError: # we may compare with something that's not a StateObject
+ except AttributeError:
+ # we may compare with something that's not a StateObject
return False
def __ne__(self, other):
@@ -29,16 +31,18 @@ class SimpleStateObject(StateObject):
"""
A StateObject with opionated conventions that tries to keep everything DRY.
- Simply put, you agree on a list of attributes and their type.
- Attributes can either be primitive types(str, tuple, bool, ...) or StateObject instances themselves.
- SimpleStateObject uses this information for the default _get_state(), _from_state(s) and _load_state(s) methods.
- Overriding _get_state or _load_state to add custom adjustments is always possible.
+ Simply put, you agree on a list of attributes and their type. Attributes can
+ either be primitive types(str, tuple, bool, ...) or StateObject instances
+ themselves. SimpleStateObject uses this information for the default
+ _get_state(), _from_state(s) and _load_state(s) methods. Overriding
+ _get_state or _load_state to add custom adjustments is always possible.
"""
_stateobject_attributes = None # none by default to raise an exception if definition was forgotten
"""
- An attribute-name -> class-or-type dict containing all attributes that should be serialized
- If the attribute is a class, this class must be a subclass of StateObject.
+ An attribute-name -> class-or-type dict containing all attributes that
+ should be serialized If the attribute is a class, this class must be a
+ subclass of StateObject.
"""
def _get_state(self):
@@ -75,4 +79,5 @@ class SimpleStateObject(StateObject):
elif hasattr(cls, "_from_state"):
setattr(self, attr, cls._from_state(state[attr]))
else:
- setattr(self, attr, cls(state[attr])) \ No newline at end of file
+ setattr(self, attr, cls(state[attr]))
+