From 9e227aecfa5b99c064d6895a5d78be1280196812 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 30 Aug 2015 02:00:42 +0000 Subject: [PATCH] Cosmesis --- pirate/data.py | 2 +- pirate/local.py | 4 ++-- pirate/pirate.py | 28 ++++++++++++++-------------- pirate/print.py | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pirate/data.py b/pirate/data.py index 1076a64..27ca62d 100644 --- a/pirate/data.py +++ b/pirate/data.py @@ -5,4 +5,4 @@ sorts = json.load(open('data/sorts.json')) default_headers = {'User-Agent': 'pirate get'} default_timeout = 10 -colored_output = True \ No newline at end of file +colored_output = True diff --git a/pirate/local.py b/pirate/local.py index 2c2c3f2..2d62382 100644 --- a/pirate/local.py +++ b/pirate/local.py @@ -1,7 +1,7 @@ import urllib.parse as parse import html.parser as parser -# create a subclass and override the handler methods + class BayParser(parser.HTMLParser): title = '' q = '' @@ -38,4 +38,4 @@ def search(db, terms): xml = open(db).readlines() parser = BayParser(' '.join(terms)) parser.feed(''.join(xml)) - return parser.results \ No newline at end of file + return parser.results diff --git a/pirate/pirate.py b/pirate/pirate.py index 15ad1e5..26d4211 100755 --- a/pirate/pirate.py +++ b/pirate/pirate.py @@ -3,7 +3,7 @@ import os import argparse import subprocess import configparser -import socket +import socket import urllib.request as request import urllib.error import webbrowser @@ -30,7 +30,7 @@ def load_config(): config.set('LocalDB', 'enabled', 'false') config.set('LocalDB', 'path', expanduser('~/downloads/pirate-get/db')) - config.add_section('Misc') + config.add_section('Misc') config.set('Misc', 'openCommand', '') config.set('Misc', 'transmission', 'false') config.set('Misc', 'colors', 'true') @@ -58,8 +58,8 @@ def parse_cmd(cmd, url): ret = [i[0].strip().replace('%s', url) for i in ret] ret_no_quotes = [] for item in ret: - if ((item[0] == "'" and item[-1] == "'") or ( - item[0] == '"' and item[-1] == '"')): + if ((item[0] == "'" and item[-1] == "'") or + (item[0] == '"' and item[-1] == '"')): ret_no_quotes.append(item[1:-1]) else: ret_no_quotes.append(item) @@ -70,7 +70,7 @@ def main(): config = load_config() parser = argparse.ArgumentParser( - description='finds and downloads torrents from the Pirate Bay') + description='finds and downloads torrents from the Pirate Bay') parser.add_argument('-b', dest='browse', action='store_true', help='display in Browse mode') @@ -82,7 +82,7 @@ def main(): help='specify a sort option', default='SeedersDsc') parser.add_argument('-R', dest='recent', action='store_true', help='torrents uploaded in the last 48hours.' - '*ignored in searches*') + '*ignored in searches*') parser.add_argument('-l', dest='list_categories', action='store_true', help='list categories') @@ -124,8 +124,7 @@ def main(): args = parser.parse_args() if (config.getboolean('Misc', 'colors') and not args.color - or not config.getboolean('Misc', 'colors')): - #global colored_output + or not config.getboolean('Misc', 'colors')): pirate.data.colored_output = False if args.save_directory: @@ -182,17 +181,18 @@ def main(): for mirror in mirrors: try: print('Trying', mirror, end='... ') - mags, sizes, uploaded, ids = pirate.torrent.remote(args, mirror) + mags, sizes, uploaded, ids = pirate.torrent.remote(args, + mirror) except (urllib.error.URLError, socket.timeout, - IOError, ValueError): + IOError, ValueError): print('Failed', color='WARN') else: site = mirror print('Ok', color='alt') break else: - print('No available mirrors :(', color='WARN') - return + print('No available mirrors :(', color='WARN') + return if not mags: print('No results') @@ -212,8 +212,8 @@ def main(): print("\nSelect links (Type 'h' for more options" ", 'q' to quit)", end='\b', color='alt') try: - l=input(': ') - except KeyboardInterrupt : + l = input(': ') + except KeyboardInterrupt: print('\nCancelled.') return diff --git a/pirate/print.py b/pirate/print.py index f3e2e83..c971e34 100644 --- a/pirate/print.py +++ b/pirate/print.py @@ -58,7 +58,7 @@ def search_results(mags, sizes, uploaded, local): else: no_seeders, no_leechers = map(int, magnet[1:]) size, unit = (float(sizes[m][0]), - sizes[m][1]) if sizes else (0, '???') + sizes[m][1]) if sizes else (0, '???') date = uploaded[m] # compute the S/L ratio (Higher is better) @@ -68,7 +68,7 @@ def search_results(mags, sizes, uploaded, local): ratio = float('inf') line = ('{:4} {:5} {:5} {:5.1f} {:5.1f}' - ' {:3} {:<11} {:{length}}') + ' {:3} {:<11} {:{length}}') content = [m, no_seeders, no_leechers, ratio, size, unit, date, torrent_name[:columns - 52]] @@ -124,4 +124,4 @@ def file_lists(chosen_links, mags, site, identifiers): for f in files: print('{0[0]:>11} {0[1]}'.format(f), color=cur_color) - cur_color = 'zebra_0' if (cur_color == 'zebra_1') else 'zebra_1' \ No newline at end of file + cur_color = 'zebra_0' if (cur_color == 'zebra_1') else 'zebra_1'