aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/mutual_friends.py6
-rw-r--r--bin/online_sessions.py48
-rw-r--r--bin/track_status.py18
3 files changed, 36 insertions, 36 deletions
diff --git a/bin/mutual_friends.py b/bin/mutual_friends.py
index 8e6e584..29f92d9 100644
--- a/bin/mutual_friends.py
+++ b/bin/mutual_friends.py
@@ -70,11 +70,11 @@ class OutputFormat(Enum):
else:
raise NotImplementedError('unsupported output format: ' + str(self))
-def _parse_output_format(s):
+def _parse_output_format(src):
try:
- return OutputFormat(s)
+ return OutputFormat(src)
except ValueError:
- raise argparse.ArgumentTypeError('invalid output format: ' + s)
+ raise argparse.ArgumentTypeError('invalid output format: ' + src)
def _parse_args(args=sys.argv):
parser = argparse.ArgumentParser(
diff --git a/bin/online_sessions.py b/bin/online_sessions.py
index dc1a2ee..a42e0dd 100644
--- a/bin/online_sessions.py
+++ b/bin/online_sessions.py
@@ -145,17 +145,17 @@ class OutputWriterJSON:
raise NotImplementedError('unsupported grouping: ' + str(group_by))
return OutputWriterJSON._CONVERT_KEY[group_by](key)
- def _write(self, x):
- self._fd.write(json.dumps(x, indent=3, ensure_ascii=False))
+ def _write(self, entries):
+ self._fd.write(json.dumps(entries, indent=3, ensure_ascii=False))
self._fd.write('\n')
def process_database(self, group_by, db_reader, time_from=None, time_to=None):
- arr = []
+ entries = []
for key, duration in group_by.group(db_reader, time_from, time_to).items():
- obj = self._key_to_object(group_by, key)
- obj[self._DURATION_FIELD] = str(duration)
- arr.append(obj)
- self._write(arr)
+ entry = self._key_to_object(group_by, key)
+ entry[self._DURATION_FIELD] = str(duration)
+ entries.append(entry)
+ self._write(entries)
class BarChartBuilder:
_BAR_HEIGHT = 1.
@@ -187,9 +187,9 @@ class BarChartBuilder:
def get_value_labels(self):
return self._get_value_axis().get_ticklabels()
- def set_value_label_formatter(self, fn):
+ def set_value_label_formatter(self, handler):
from matplotlib.ticker import FuncFormatter
- self._get_value_axis().set_major_formatter(FuncFormatter(fn))
+ self._get_value_axis().set_major_formatter(FuncFormatter(handler))
def set_integer_values_only(self):
from matplotlib.ticker import MaxNLocator
@@ -289,8 +289,8 @@ class OutputWriterPlot:
return str(timedelta(seconds=seconds))
@staticmethod
- def _duration_to_seconds(td):
- return td.total_seconds()
+ def _duration_to_seconds(duration):
+ return duration.total_seconds()
@staticmethod
def _extract_labels(group_by, durations):
@@ -350,34 +350,34 @@ class OutputFormat(Enum):
def __str__(self):
return self.value
-def _parse_group_by(s):
+def _parse_group_by(src):
try:
- return GroupBy(s)
+ return GroupBy(src)
except ValueError:
- raise argparse.ArgumentTypeError('invalid "group by" value: ' + s)
+ raise argparse.ArgumentTypeError('invalid "group by" value: ' + src)
-def _parse_database_format(s):
+def _parse_database_format(src):
try:
- return DatabaseFormat(s)
+ return DatabaseFormat(src)
except ValueError:
- raise argparse.ArgumentTypeError('invalid database format: ' + s)
+ raise argparse.ArgumentTypeError('invalid database format: ' + src)
-def _parse_output_format(s):
+def _parse_output_format(src):
try:
- return OutputFormat(s)
+ return OutputFormat(src)
except ValueError:
- raise argparse.ArgumentTypeError('invalid output format: ' + s)
+ raise argparse.ArgumentTypeError('invalid output format: ' + src)
_DATE_RANGE_LIMIT_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
-def _parse_date_range_limit(s):
+def _parse_date_range_limit(src):
try:
- dt = datetime.strptime(s, _DATE_RANGE_LIMIT_FORMAT)
- return dt.replace(tzinfo=timezone.utc)
+ timestamp = datetime.strptime(src, _DATE_RANGE_LIMIT_FORMAT)
+ return timestamp.replace(tzinfo=timezone.utc)
except ValueError:
msg = 'invalid date range limit (must be in the \'{}\' format): {}'
raise argparse.ArgumentTypeError(
- msg.format(_DATE_RANGE_LIMIT_FORMAT, s))
+ msg.format(_DATE_RANGE_LIMIT_FORMAT, src))
def _parse_args(args=sys.argv):
parser = argparse.ArgumentParser(
diff --git a/bin/track_status.py b/bin/track_status.py
index 84495f9..e59b0e1 100644
--- a/bin/track_status.py
+++ b/bin/track_status.py
@@ -12,20 +12,20 @@ from vk.tracking.db import Format as DatabaseFormat
DEFAULT_TIMEOUT = StatusTracker.DEFAULT_TIMEOUT
DEFAULT_DB_FORMAT = DatabaseFormat.CSV
-def _parse_positive_integer(s):
+def _parse_positive_integer(src):
try:
- x = int(s)
+ n = int(src)
except ValueError:
- raise argparse.ArgumentTypeError('must be a positive integer: ' + s)
- if x < 1:
- raise argparse.ArgumentTypeError('must be a positive integer: ' + s)
- return x
+ raise argparse.ArgumentTypeError('must be a positive integer: ' + src)
+ if n < 1:
+ raise argparse.ArgumentTypeError('must be a positive integer: ' + src)
+ return n
-def _parse_database_format(s):
+def _parse_database_format(src):
try:
- return DatabaseFormat(s)
+ return DatabaseFormat(src)
except ValueError:
- raise argparse.ArgumentTypeError('invalid database format: ' + s)
+ raise argparse.ArgumentTypeError('invalid database format: ' + src)
def _parse_args(args=sys.argv):
parser = argparse.ArgumentParser(