diff --git a/pirate/print.py b/pirate/print.py index eac3f1b..6c4f526 100644 --- a/pirate/print.py +++ b/pirate/print.py @@ -8,7 +8,7 @@ import shutil from io import BytesIO import colorama -import prettytable +import veryprettytable import pirate.data @@ -37,12 +37,12 @@ def print(*args, **kwargs): # TODO: extract the name from the search results instead of from the magnet link when possible def search_results(results, local=None): columns = shutil.get_terminal_size((80, 20)).columns - cur_color = 'zebra_0' + even = True if local: - table = prettytable.PrettyTable(['LINK', 'NAME']) + table = veryprettytable.VeryPrettyTable(['LINK', 'NAME']) else: - table = prettytable.PrettyTable(['LINK', 'SEED', 'LEECH', 'RATIO', 'SIZE', '', 'UPLOAD', 'NAME']) + table = veryprettytable.VeryPrettyTable(['LINK', 'SEED', 'LEECH', 'RATIO', 'SIZE', '', 'UPLOAD', 'NAME']) table.align['NAME'] = 'l' table.align['SEED'] = 'r' table.align['LEECH'] = 'r' @@ -55,8 +55,6 @@ def search_results(results, local=None): table.padding_width = 1 for n, result in enumerate(results): - # Alternate between colors - cur_color = 'zebra_0' if cur_color == 'zebra_1' else 'zebra_1' name = re.search(r'dn=([^\&]*)', result['magnet']) torrent_name = parse.unquote_plus(name.group(1)) @@ -80,10 +78,16 @@ def search_results(results, local=None): except ZeroDivisionError: ratio = float('inf') - content = [n, no_seeders, no_leechers, '{0:.1f}'.format(ratio), - '{0:.1f}'.format(size), unit, date, torrent_name[:columns - 53]] + content = [n, no_seeders, no_leechers, '{:.1f}'.format(ratio), + '{:.1f}'.format(size), unit, date, torrent_name[:columns - 53]] - table.add_row(content) + if even: + table.add_row(content) + else: + table.add_row(content, fore_color='blue') + + # Alternate between colors + even = not even print(table) diff --git a/setup.py b/setup.py index 0af554d..67f4029 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup(name='pirate-get', entry_points={ 'console_scripts': ['pirate-get = pirate.pirate:main'] }, - install_requires=['colorama>=0.3.3', 'pyquery>=1.2.9', 'PrettyTable>=0.7.2'], + install_requires=['colorama>=0.3.3', 'pyquery>=1.2.9', 'veryprettytable>=0.8.1'], keywords=['torrent', 'magnet', 'download', 'tpb', 'client'], classifiers=[ 'Topic :: Utilities', diff --git a/tests/test_print.py b/tests/test_print.py index 5795b5d..5e4adc7 100755 --- a/tests/test_print.py +++ b/tests/test_print.py @@ -29,7 +29,7 @@ class TestPrint(unittest.TestCase): add_row = MagicMock() align = {} mock = MockTable() - with patch('prettytable.PrettyTable', return_value=mock) as prettytable: + with patch('veryprettytable.VeryPrettyTable', return_value=mock) as prettytable: results = [{ 'magnet': 'dn=name', 'Name': 'name',