aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/vk/user.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-06-17 06:32:46 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-06-17 06:32:46 +0300
commit5d9f1fcc26d9090e2250fc39543dbff00abf8d3a (patch)
treee0ab3246951bb1f527ebd0507e864f8f3e7ec27f /vk/user.py
parentmake the status logger a database writer (diff)
downloadvk-scripts-5d9f1fcc26d9090e2250fc39543dbff00abf8d3a.tar.gz
vk-scripts-5d9f1fcc26d9090e2250fc39543dbff00abf8d3a.zip
add basic "online periods" extraction
Diffstat (limited to 'vk/user.py')
-rw-r--r--vk/user.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/vk/user.py b/vk/user.py
index 80702f6..c2ed623 100644
--- a/vk/user.py
+++ b/vk/user.py
@@ -93,10 +93,10 @@ class LastSeen(MutableMapping):
def __delitem__(self, field):
del self._fields[field]
- def __iter__(self, field):
+ def __iter__(self):
return iter(self._fields)
- def __len__(self, field):
+ def __len__(self):
return len(self._fields)
@staticmethod
@@ -199,9 +199,20 @@ class User(Hashable, MutableMapping):
else:
raise TypeError()
+ def _parse_bool(x):
+ if isinstance(x, str):
+ if str(True) == x:
+ return True
+ elif str(False) == x:
+ return False
+ else:
+ raise ValueError()
+ else:
+ return bool(x)
+
_FIELD_PARSERS = {
UserField.UID: int,
- UserField.ONLINE: bool,
+ UserField.ONLINE: _parse_bool,
UserField.LAST_SEEN: _parse_last_seen,
}