deluge.ui.console.utils package

Submodules

deluge.ui.console.utils.colors module

exception deluge.ui.console.utils.colors.BadColorString

Bases: Exception

class deluge.ui.console.utils.colors.ConsoleColorFormatter

Bases: object

Format help in a way suited to deluge CmdLine mode - colors, format, indentation…

format_colors(string)
replace_dict = {'(?<![\\-a-z])(-[a-zA-Z0-9])': '{!red!}%s{!input!}', '(\\[|\\])': '{!info!}%s{!input!}', '--[_\\-a-zA-Z0-9]+': '{!green!}%s{!input!}', '<command>': '{!green!}%s{!input!}', '<download-folder>': '{!yellow!}%s{!input!}', '<key>': '{!cyan!}%s{!input!}', '<state>': '{!yellow!}%s{!input!}', '<tab>': '{!white!}%s{!input!}', '<torrent-file>': '{!green!}%s{!input!}', '<torrent-id>': '{!green!}%s{!input!}', '<torrent>': '{!green!}%s{!input!}', '<value>': '{!cyan!}%s{!input!}', '[_A-Z]{3,}': '{!cyan!}%s{!input!}', '\\.\\.\\.': '{!yellow!}%s{!input!}', '\\s\\*\\s': '{!blue!}%s{!input!}', 'usage:': '{!info!}%s{!input!}'}
deluge.ui.console.utils.colors.check_tag_count(string)

Raise BadColorString if color tag open/close not equal.

deluge.ui.console.utils.colors.get_color_pair(fg, bg)
deluge.ui.console.utils.colors.get_line_length(line)

Returns the string length without the color formatting.

deluge.ui.console.utils.colors.get_line_width(line)

Get width of string considering double width characters

deluge.ui.console.utils.colors.init_colors()
deluge.ui.console.utils.colors.parse_color_string(string)

Parses a string and returns a list of 2-tuples (color, string).

Parameters

string (str) – The string to parse.

deluge.ui.console.utils.colors.replace_tabs(line)

Returns a string with tabs replaced with spaces.

deluge.ui.console.utils.colors.strip_colors(line)

Returns a string with the color formatting removed.

deluge.ui.console.utils.column module

deluge.ui.console.utils.column.get_column_value(name, state)
deluge.ui.console.utils.column.get_required_fields(cols)

deluge.ui.console.utils.common module

deluge.ui.console.utils.curses_util module

class deluge.ui.console.utils.curses_util.Curser

Bases: object

INVISIBLE = 0
NORMAL = 1
VERY_VISIBLE = 2
class deluge.ui.console.utils.curses_util.ReadState

Bases: object

CHANGED = 2
IGNORED = 0
READ = 1
deluge.ui.console.utils.curses_util.is_int_chr(c)
deluge.ui.console.utils.curses_util.is_printable_chr(c)
deluge.ui.console.utils.curses_util.safe_curs_set(visibility)
Parameters

visibility (int) – 0, 1, or 2, for invisible, normal, or very visible

curses.curs_set fails on monochrome terminals so use this to ignore errors

deluge.ui.console.utils.format_utils module

deluge.ui.console.utils.format_utils.delete_alt_backspace(input_text, input_cursor, sep_chars=' *?!._~-#$^;\'"/')

Remove text from input_text on ALT+backspace Stop removing when countering any of the sep chars

deluge.ui.console.utils.format_utils.f_progressbar(progress, width)

Returns a string of a progress bar.

Parameters

progress – float, a value between 0-100

Returns

str, a progress bar based on width

deluge.ui.console.utils.format_utils.f_seedrank_dash(seed_rank, seeding_time)

Display value if seeding otherwise dash

deluge.ui.console.utils.format_utils.format_column(col, lim)
deluge.ui.console.utils.format_utils.format_date_dash(time)
deluge.ui.console.utils.format_utils.format_date_never(time)
deluge.ui.console.utils.format_utils.format_float(x)
deluge.ui.console.utils.format_utils.format_pieces(num, size)
deluge.ui.console.utils.format_utils.format_priority(prio)
deluge.ui.console.utils.format_utils.format_progress(value)
deluge.ui.console.utils.format_utils.format_queue(qnum)
deluge.ui.console.utils.format_utils.format_row(row, column_widths)
deluge.ui.console.utils.format_utils.format_seeds_peers(num, total)
deluge.ui.console.utils.format_utils.format_size(size)
deluge.ui.console.utils.format_utils.format_speed(speed)
deluge.ui.console.utils.format_utils.format_time(time)
deluge.ui.console.utils.format_utils.ftotal_sized(first, second)
deluge.ui.console.utils.format_utils.pad_string(string, length, character=' ', side='right')

Pad string with specified character to desired length, considering double width characters.

deluge.ui.console.utils.format_utils.remove_formatting(string)
deluge.ui.console.utils.format_utils.shorten_hash(tid, space_left, min_width=13, placeholder='...')

Shorten the supplied torrent infohash by removing chars from the middle.

Use a placeholder to indicate shortened. If unable to shorten will justify so entire tid is on the next line.

deluge.ui.console.utils.format_utils.strwidth(string)

Measure width of a string considering asian double width characters

deluge.ui.console.utils.format_utils.trim_string(string, w, have_dbls)
deluge.ui.console.utils.format_utils.wrap_string(string, width, min_lines=0, strip_colors=True)

Wrap a string to fit in a particular width. Returns a list of output lines.

Parameters
  • string – str, the string to wrap

  • width – int, the maximum width of a line of text

  • min_lines – int, extra lines will be added so the output tuple contains at least min_lines lines

  • strip_colors – boolean, if True, text in {!!} blocks will not be considered as adding to the width of the line. They will still be present in the output.

Module contents