aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.pylintrc92
-rw-r--r--online_duration.py2
-rw-r--r--vk/api.py4
-rw-r--r--vk/error.py5
-rw-r--r--vk/platform.py8
-rw-r--r--vk/tracking/__init__.py4
-rw-r--r--vk/tracking/db/backend/__init__.py4
-rw-r--r--vk/tracking/db/backend/log.py2
-rw-r--r--vk/tracking/db/format.py12
-rw-r--r--vk/tracking/online_streaks.py2
-rw-r--r--vk/tracking/status_tracker.py10
-rw-r--r--vk/user.py2
12 files changed, 120 insertions, 27 deletions
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..99f1f5d
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,92 @@
+[MESSAGES CONTROL]
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=missing-docstring,too-many-public-methods,too-few-public-methods
+
+[BASIC]
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=
+
+# Colon-delimited sets of names that determine each other's naming style when
+# the name regexes allow several styles.
+name-group=
+
+# Include a hint for the correct naming format with invalid-name
+include-naming-hint=no
+
+# Regular expression matching correct inline iteration names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Naming hint for inline iteration names
+inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
+
+# Regular expression matching correct method names
+method-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for method names
+method-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Naming hint for class names
+class-name-hint=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression matching correct attribute names
+attr-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Naming hint for attribute names
+attr-name-hint=[a-z_][a-z0-9_]{0,30}$
+
+# Regular expression matching correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for function names
+function-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Naming hint for module names
+module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression matching correct class attribute names
+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{1,30}|(__.*__))$
+
+# Naming hint for class attribute names
+class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{1,30}|(__.*__))$
+
+# Regular expression matching correct variable names
+variable-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Naming hint for variable names
+variable-name-hint=[a-z_][a-z0-9_]{0,30}$
+
+# Regular expression matching correct argument names
+argument-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Naming hint for argument names
+argument-name-hint=[a-z_][a-z0-9_]{0,30}$
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=^_
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
diff --git a/online_duration.py b/online_duration.py
index 9defd7f..d2d9e34 100644
--- a/online_duration.py
+++ b/online_duration.py
@@ -12,8 +12,8 @@ import sys
import matplotlib.pyplot as plt
import numpy as np
+from vk.tracking import OnlineStreakEnumerator, Weekday
from vk.tracking.db import Format as DatabaseFormat
-from vk.tracking.online_streaks import OnlineStreakEnumerator, Weekday
from vk.user import UserField
class Grouping(Enum):
diff --git a/vk/api.py b/vk/api.py
index 6b251d0..bf59636 100644
--- a/vk/api.py
+++ b/vk/api.py
@@ -50,10 +50,10 @@ class API:
with urllib.request.urlopen(url) as request:
response = json.loads(request.read().decode())
if 'response' not in response:
- raise vk.error.InvalidResponseError(response)
+ raise vk.error.InvalidAPIResponseError(response)
return response['response']
except URLError:
- raise vk.error.ConnectionError()
+ raise vk.error.APIConnectionError()
@staticmethod
def _format_param_values(xs):
diff --git a/vk/error.py b/vk/error.py
index b80db4e..4182449 100644
--- a/vk/error.py
+++ b/vk/error.py
@@ -5,12 +5,13 @@
class APIError(RuntimeError):
pass
-class InvalidResponseError(APIError):
+class InvalidAPIResponseError(APIError):
def __init__(self, response):
+ super().__init__()
self.response = response
def __str__(self):
return str(self.response)
-class ConnectionError(APIError):
+class APIConnectionError(APIError):
pass
diff --git a/vk/platform.py b/vk/platform.py
index 4a9d8b6..5f87e41 100644
--- a/vk/platform.py
+++ b/vk/platform.py
@@ -28,16 +28,16 @@ class Platform(Enum):
return s
return s[:m.start()] + m.group().upper() + s[m.end():]
- def get_description_for_header(self):
+ def get_descr_header(self):
return self._uppercase_first_letter(_PLATFORM_DESCRIPTIONS[self])
- def get_description_for_sentence(self):
+ def get_descr_text(self):
s = _PLATFORM_DESCRIPTIONS[self]
s = s.replace('unrecognized', 'an unrecognized')
return 'the ' + s
- def get_description_for_sentence_beginning(self):
- return self._uppercase_first_letter(self.get_description_for_sentence())
+ def get_descr_text_capitalized(self):
+ return self._uppercase_first_letter(self.get_descr_text())
_PLATFORM_DESCRIPTIONS = {
Platform.MOBILE: '"mobile" web version (or unrecognized mobile app)',
diff --git a/vk/tracking/__init__.py b/vk/tracking/__init__.py
index 0f9c422..cfc80ea 100644
--- a/vk/tracking/__init__.py
+++ b/vk/tracking/__init__.py
@@ -2,7 +2,7 @@
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.
-from .online_streaks import OnlineStreakEnumerator
+from .online_streaks import OnlineStreakEnumerator, Weekday
from .status_tracker import StatusTracker
-__all__ = 'online_streaks', 'status_tracker',
+__all__ = 'online_streaks', 'status_tracker',
diff --git a/vk/tracking/db/backend/__init__.py b/vk/tracking/db/backend/__init__.py
index 4b3c278..68de924 100644
--- a/vk/tracking/db/backend/__init__.py
+++ b/vk/tracking/db/backend/__init__.py
@@ -2,4 +2,6 @@
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.
-__all__ = 'csv', 'log', 'null'
+from . import csv, log, null
+
+__all__ = 'csv', 'log', 'null',
diff --git a/vk/tracking/db/backend/log.py b/vk/tracking/db/backend/log.py
index 625257b..03548eb 100644
--- a/vk/tracking/db/backend/log.py
+++ b/vk/tracking/db/backend/log.py
@@ -64,7 +64,7 @@ class Writer:
return '{} was last seen at {} using {}.'.format(
Writer._format_user(user),
user.get_last_seen_time_local(),
- user.get_last_seen_platform().get_description_for_sentence())
+ user.get_last_seen_platform().get_descr_text())
@staticmethod
def _format_user_went_online(user):
diff --git a/vk/tracking/db/format.py b/vk/tracking/db/format.py
index 4856094..862c20e 100644
--- a/vk/tracking/db/format.py
+++ b/vk/tracking/db/format.py
@@ -4,7 +4,7 @@
from enum import Enum
-from .backend import *
+from . import backend
class Format(Enum):
CSV = 'csv'
@@ -13,21 +13,21 @@ class Format(Enum):
def create_writer(self, fd):
if self is Format.CSV:
- return csv.Writer(fd)
+ return backend.csv.Writer(fd)
elif self is Format.LOG:
- return log.Writer(fd)
+ return backend.log.Writer(fd)
elif self is Format.NULL:
- return null.Writer(fd)
+ return backend.null.Writer(fd)
else:
raise NotImplementedError('unsupported database format: ' + str(self))
def create_reader(self, fd):
if self is Format.CSV:
- return csv.Reader(fd)
+ return backend.csv.Reader(fd)
elif self is Format.LOG:
raise NotImplementedError()
elif self is Format.NULL:
- return null.Reader(fd)
+ return backend.null.Reader(fd)
else:
raise NotImplementedError('unsupported database format: ' + str(self))
diff --git a/vk/tracking/online_streaks.py b/vk/tracking/online_streaks.py
index 467a1d5..db24053 100644
--- a/vk/tracking/online_streaks.py
+++ b/vk/tracking/online_streaks.py
@@ -7,8 +7,6 @@ from collections.abc import MutableMapping
from datetime import timedelta
from enum import Enum
-from vk.user import User
-
class Weekday(Enum):
MONDAY = 0
TUESDAY = 1
diff --git a/vk/tracking/status_tracker.py b/vk/tracking/status_tracker.py
index 8faea8e..bb5f186 100644
--- a/vk/tracking/status_tracker.py
+++ b/vk/tracking/status_tracker.py
@@ -22,9 +22,9 @@ class StatusTracker:
time.sleep(self._timeout)
def add_database_writer(self, writer):
- self.add_initial_status_handler(lambda user: writer.on_initial_status(user))
- self.add_status_update_handler(lambda user: writer.on_status_update(user))
- self.add_connection_error_handler(lambda e: writer.on_connection_error(e))
+ self.add_initial_status_handler(writer.on_initial_status)
+ self.add_status_update_handler(writer.on_status_update)
+ self.add_connection_error_handler(writer.on_connection_error)
def add_initial_status_handler(self, fn):
self._assert_is_callback(fn)
@@ -64,7 +64,7 @@ class StatusTracker:
while True:
try:
return self._query_status(uids)
- except vk.error.ConnectionError as e:
+ except vk.error.APIConnectionError as e:
self._notify_connection_error(e)
self._wait_after_connection_error()
@@ -73,7 +73,7 @@ class StatusTracker:
self._wait_after_connection_error()
try:
return self._query_status(uids)
- except vk.error.ConnectionError as e:
+ except vk.error.APIConnectionError as e:
self._notify_connection_error(e)
@staticmethod
diff --git a/vk/user.py b/vk/user.py
index 736c4ba..00a1674 100644
--- a/vk/user.py
+++ b/vk/user.py
@@ -56,7 +56,7 @@ class User(Hashable, MutableMapping):
return self.get_uid() == other.get_uid()
#return self._fields == other._fields
- def __hash__(self, fields=None):
+ def __hash__(self):
return hash(self.get_uid())
def __getitem__(self, field):