diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/mutual_friends.py | 6 | ||||
-rw-r--r-- | bin/online_sessions.py | 34 | ||||
-rw-r--r-- | bin/track_status.py | 14 |
3 files changed, 27 insertions, 27 deletions
diff --git a/bin/mutual_friends.py b/bin/mutual_friends.py index 29f92d9..8e6e584 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(src): +def _parse_output_format(s): try: - return OutputFormat(src) + return OutputFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid output format: ' + src) + raise argparse.ArgumentTypeError('invalid output format: ' + s) def _parse_args(args=sys.argv): parser = argparse.ArgumentParser( diff --git a/bin/online_sessions.py b/bin/online_sessions.py index a42e0dd..ac182e7 100644 --- a/bin/online_sessions.py +++ b/bin/online_sessions.py @@ -187,9 +187,9 @@ class BarChartBuilder: def get_value_labels(self): return self._get_value_axis().get_ticklabels() - def set_value_label_formatter(self, handler): + def set_value_label_formatter(self, fn): from matplotlib.ticker import FuncFormatter - self._get_value_axis().set_major_formatter(FuncFormatter(handler)) + self._get_value_axis().set_major_formatter(FuncFormatter(fn)) 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(duration): - return duration.total_seconds() + def _duration_to_seconds(td): + return td.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(src): +def _parse_group_by(s): try: - return GroupBy(src) + return GroupBy(s) except ValueError: - raise argparse.ArgumentTypeError('invalid "group by" value: ' + src) + raise argparse.ArgumentTypeError('invalid "group by" value: ' + s) -def _parse_database_format(src): +def _parse_database_format(s): try: - return DatabaseFormat(src) + return DatabaseFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid database format: ' + src) + raise argparse.ArgumentTypeError('invalid database format: ' + s) -def _parse_output_format(src): +def _parse_output_format(s): try: - return OutputFormat(src) + return OutputFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid output format: ' + src) + raise argparse.ArgumentTypeError('invalid output format: ' + s) _DATE_RANGE_LIMIT_FORMAT = '%Y-%m-%dT%H:%M:%SZ' -def _parse_date_range_limit(src): +def _parse_date_range_limit(s): try: - timestamp = datetime.strptime(src, _DATE_RANGE_LIMIT_FORMAT) - return timestamp.replace(tzinfo=timezone.utc) + dt = datetime.strptime(s, _DATE_RANGE_LIMIT_FORMAT) + return dt.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, src)) + msg.format(_DATE_RANGE_LIMIT_FORMAT, s)) def _parse_args(args=sys.argv): parser = argparse.ArgumentParser( diff --git a/bin/track_status.py b/bin/track_status.py index e59b0e1..c221c53 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(src): +def _parse_positive_integer(s): try: - n = int(src) + n = int(s) except ValueError: - raise argparse.ArgumentTypeError('must be a positive integer: ' + src) + raise argparse.ArgumentTypeError('must be a positive integer: ' + s) if n < 1: - raise argparse.ArgumentTypeError('must be a positive integer: ' + src) + raise argparse.ArgumentTypeError('must be a positive integer: ' + s) return n -def _parse_database_format(src): +def _parse_database_format(s): try: - return DatabaseFormat(src) + return DatabaseFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid database format: ' + src) + raise argparse.ArgumentTypeError('invalid database format: ' + s) def _parse_args(args=sys.argv): parser = argparse.ArgumentParser( |