Skip to content

Commit

Permalink
Fixed some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mailund committed Sep 28, 2016
1 parent 78e1fa6 commit 73036e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
23 changes: 15 additions & 8 deletions statusbar/__init__.py
@@ -1,6 +1,5 @@
"""
Module for constructing text-based status updates.
"""
"""Module for constructing text-based status updates."""

import shutil
import itertools
import colorama
Expand Down Expand Up @@ -54,11 +53,13 @@ class ProgressBar:
"""Class responsible for showing progress of a task."""

def __init__(self, sep_start='[', sep_end=']'):
"""Construct a progress bar."""
self._progress_chunks = []
self.sep_start = sep_start
self.sep_end = sep_end

def set_progress_brackets(self, start, end):
"""Set brackets to set around a progress bar."""
self.sep_start = start
self.sep_end = end

Expand Down Expand Up @@ -98,6 +99,7 @@ def _get_chunk_sizes(self, width):
return chunk_widths

def format_progress(self, width):
"""Create the formatted string that displays the progress."""
chunk_widths = self._get_chunk_sizes(width)
progress_chunks = [chunk.format_chunk(chunk_width)
for (chunk, chunk_width)
Expand All @@ -110,8 +112,10 @@ def format_progress(self, width):

def summary_length(self):
"""Calculate how long a string is needed to show a summary string.
This is not simply the length of the formatted summary string
since that string might contain ANSI codes."""
since that string might contain ANSI codes.
"""
chunk_counts = [chunk.count for chunk in self._progress_chunks]
numbers_width = sum(max(1, ceil(log10(count + 1)))
for count in chunk_counts)
Expand All @@ -126,17 +130,20 @@ def format_summary(self):


class StatusBar:
"""Class for displaying status bars. These bars consists of a label,
a progress bar, and statistics/summaries of the progress."""
"""Class for displaying status bars.
These bars consists of a label, a progress bar, and statistics/summaries
of the progress.
"""

def __init__(self, label,
progress_sep_start='[', progress_sep_end=']'):
"""Construct a status bar."""
self.label = label
self._progress = ProgressBar(progress_sep_start, progress_sep_end)

def set_progress_brackets(self, start, end):
"""Define how the brackets around the progress part of the statusbar
should look."""
"""Define which braces should be used around the progress bar."""
self._progress.set_progress_brackets(start, end)

def add_progress(self, count, symbol='#',
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Expand Up @@ -166,6 +166,7 @@ def test_summary_string(self):
self.assertEqual(len(summary_string), 7)
self.assertEqual(summary_string, "100/199")


class TestStatusBar(unittest.TestCase):
"""Test of a status bar."""

Expand Down

0 comments on commit 73036e1

Please sign in to comment.