summaryrefslogtreecommitdiffstats
path: root/deluge/ui/console/utils
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/ui/console/utils')
-rw-r--r--deluge/ui/console/utils/colors.py11
-rw-r--r--deluge/ui/console/utils/column.py3
-rw-r--r--deluge/ui/console/utils/common.py3
-rw-r--r--deluge/ui/console/utils/curses_util.py7
-rw-r--r--deluge/ui/console/utils/format_utils.py19
5 files changed, 14 insertions, 29 deletions
diff --git a/deluge/ui/console/utils/colors.py b/deluge/ui/console/utils/colors.py
index 587c1f3..cc414fe 100644
--- a/deluge/ui/console/utils/colors.py
+++ b/deluge/ui/console/utils/colors.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
import re
@@ -91,8 +88,8 @@ def init_colors():
curses.init_pair(counter, fg, bg)
color_pairs[(fg_name, bg_name)] = counter
counter += 1
- except curses.error as ex:
- log.warning('Error: %s', ex)
+ except (curses.error, ValueError) as ex:
+ log.debug(f'Color pair {fg_name} {bg_name} not available: {ex}')
return counter
# Create the color_pairs dict
@@ -271,7 +268,7 @@ def parse_color_string(string):
last_color_attr = color_pair
attrs = attrs[2:] # Remove colors
except KeyError:
- raise BadColorString('Bad color value in tag: %s,%s' % (fg, bg))
+ raise BadColorString(f'Bad color value in tag: {fg},{bg}')
# Check for additional attributes and OR them to the color_pair
color_pair = apply_attrs(color_pair, attrs)
last_color_attr = color_pair
@@ -292,7 +289,7 @@ def parse_color_string(string):
return ret
-class ConsoleColorFormatter(object):
+class ConsoleColorFormatter:
"""
Format help in a way suited to deluge CmdLine mode - colors, format, indentation...
"""
diff --git a/deluge/ui/console/utils/column.py b/deluge/ui/console/utils/column.py
index d932159..ecbe04b 100644
--- a/deluge/ui/console/utils/column.py
+++ b/deluge/ui/console/utils/column.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import copy
import logging
diff --git a/deluge/ui/console/utils/common.py b/deluge/ui/console/utils/common.py
index df1c079..fdc88c4 100644
--- a/deluge/ui/console/utils/common.py
+++ b/deluge/ui/console/utils/common.py
@@ -1,12 +1,9 @@
-# -*- coding: utf-8 -*-
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
TORRENT_OPTIONS = {
'max_download_speed': float,
'max_upload_speed': float,
diff --git a/deluge/ui/console/utils/curses_util.py b/deluge/ui/console/utils/curses_util.py
index a0cd6dc..50b0444 100644
--- a/deluge/ui/console/utils/curses_util.py
+++ b/deluge/ui/console/utils/curses_util.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
try:
import curses
except ImportError:
@@ -39,7 +36,7 @@ def is_int_chr(c):
return c > 47 and c < 58
-class Curser(object):
+class Curser:
INVISIBLE = 0
NORMAL = 1
VERY_VISIBLE = 2
@@ -59,7 +56,7 @@ def safe_curs_set(visibility):
pass
-class ReadState(object):
+class ReadState:
IGNORED = 0
READ = 1
CHANGED = 2
diff --git a/deluge/ui/console/utils/format_utils.py b/deluge/ui/console/utils/format_utils.py
index 029fb20..50ec191 100644
--- a/deluge/ui/console/utils/format_utils.py
+++ b/deluge/ui/console/utils/format_utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import re
from collections import deque
from unicodedata import east_asian_width, normalize
@@ -98,7 +95,7 @@ def f_seedrank_dash(seed_rank, seeding_time):
def ftotal_sized(first, second):
- return '%s (%s)' % (
+ return '{} ({})'.format(
deluge.common.fsize(first, shortform=True),
deluge.common.fsize(second, shortform=True),
)
@@ -159,7 +156,7 @@ def format_column(col, lim):
if size >= lim - 1:
return trim_string(col, lim, dbls > 0)
else:
- return '%s%s' % (col, ' ' * (lim - size))
+ return '{}{}'.format(col, ' ' * (lim - size))
def format_row(row, column_widths):
@@ -213,7 +210,7 @@ def wrap_string(string, width, min_lines=0, strip_colors=True):
mtc = mtchs.popleft() - offset
clr = clrs.popleft()
end_pos += len(clr)
- s = '%s%s%s' % (s[:mtc], clr, s[mtc:])
+ s = f'{s[:mtc]}{clr}{s[mtc:]}'
return s
for s in s1:
@@ -238,11 +235,11 @@ def wrap_string(string, width, min_lines=0, strip_colors=True):
else:
cstr = s
- def append_indent(l, string, offset):
+ def append_indent(line, string, offset):
"""Prepends indent to string if specified"""
if indent and offset != 0:
string = indent + string
- l.append(string)
+ line.append(string)
while cstr:
# max with for a line. If indent is specified, we account for this
@@ -290,7 +287,7 @@ def wrap_string(string, width, min_lines=0, strip_colors=True):
last_color_string = ''
for i, line in enumerate(ret):
if i != 0:
- ret[i] = '%s%s' % (last_color_string, ret[i])
+ ret[i] = f'{last_color_string}{ret[i]}'
colors = re.findall('\\{![^!]+!\\}', line)
if colors:
@@ -313,9 +310,9 @@ def pad_string(string, length, character=' ', side='right'):
w = strwidth(string)
diff = length - w
if side == 'left':
- return '%s%s' % (character * diff, string)
+ return f'{character * diff}{string}'
elif side == 'right':
- return '%s%s' % (string, character * diff)
+ return f'{string}{character * diff}'
def delete_alt_backspace(input_text, input_cursor, sep_chars=' *?!._~-#$^;\'"/'):