mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-10 17:35:00 -06:00
Reformat python code to be compliant with PEP8
The following command is used: `pycodestyle --ignore=E265,E722 --max-line-length=100 <py files>`
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#VERSION: 1.45
|
||||
#VERSION: 1.46
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -24,21 +24,26 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys, codecs
|
||||
import codecs
|
||||
import sys
|
||||
from io import open
|
||||
|
||||
# Force UTF-8 printing
|
||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
|
||||
|
||||
|
||||
def prettyPrinter(dictionary):
|
||||
dictionary['size'] = anySizeToBytes(dictionary['size'])
|
||||
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "), str(dictionary["size"]), str(dictionary["seeds"]), str(dictionary["leech"]), dictionary["engine_url"]))
|
||||
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "),
|
||||
str(dictionary["size"]), str(dictionary["seeds"]),
|
||||
str(dictionary["leech"]), dictionary["engine_url"]))
|
||||
if 'desc_link' in dictionary:
|
||||
outtext = "|".join((outtext, dictionary["desc_link"]))
|
||||
|
||||
with open(1, 'w', encoding='utf-8', closefd=False) as utf8_stdout:
|
||||
utf8_stdout.write(unicode("".join((outtext, "\n"))))
|
||||
|
||||
|
||||
def anySizeToBytes(size_string):
|
||||
"""
|
||||
Convert a string like '1 KB' to '1024' (bytes)
|
||||
@@ -63,6 +68,6 @@ def anySizeToBytes(size_string):
|
||||
|
||||
# convert
|
||||
units_dict = {'T': 40, 'G': 30, 'M': 20, 'K': 10}
|
||||
if units_dict.has_key(short_unit):
|
||||
if short_unit in units_dict:
|
||||
size = size * 2**units_dict[short_unit]
|
||||
return int(size)
|
||||
|
||||
Reference in New Issue
Block a user