diff options
Diffstat (limited to 'deluge/ui/console/parser.py')
-rw-r--r-- | deluge/ui/console/parser.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/deluge/ui/console/parser.py b/deluge/ui/console/parser.py index 27f2485..c0686b1 100644 --- a/deluge/ui/console/parser.py +++ b/deluge/ui/console/parser.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 print_function, unicode_literals - import argparse import shlex @@ -23,13 +20,13 @@ class OptionParserError(Exception): class ConsoleBaseParser(argparse.ArgumentParser): def format_help(self): """Differs from ArgumentParser.format_help by adding the raw epilog - as formatted in the string. Default bahavior mangles the formatting. + as formatted in the string. Default behavior mangles the formatting. """ # Handle epilog manually to keep the text formatting epilog = self.epilog self.epilog = '' - help_str = super(ConsoleBaseParser, self).format_help() + help_str = super().format_help() if epilog is not None: help_str += epilog self.epilog = epilog @@ -51,7 +48,7 @@ class ConsoleCommandParser(ConsoleBaseParser): for cmd_line in cmd_lines: cmds = shlex.split(cmd_line) - cmd_options = super(ConsoleCommandParser, self).parse_args(args=cmds) + cmd_options = super().parse_args(args=cmds) cmd_options.command = cmds[0] command_options.append(cmd_options) @@ -60,14 +57,14 @@ class ConsoleCommandParser(ConsoleBaseParser): def parse_args(self, args=None): """Parse known UI args and handle common and process group options. - Notes: - If started by deluge entry script this has already been done. + Notes: + If started by deluge entry script this has already been done. - Args: - args (list, optional): The arguments to parse. + Args: + args (list, optional): The arguments to parse. - Returns: - argparse.Namespace: The parsed arguments. + Returns: + argparse.Namespace: The parsed arguments. """ from deluge.ui.ui_entry import AMBIGUOUS_CMD_ARGS @@ -96,7 +93,7 @@ class ConsoleCommandParser(ConsoleBaseParser): options = self.base_parser.parse_args(args=args) options.parsed_cmds = [] else: - options = super(ConsoleCommandParser, self).parse_args(args=args) + options = super().parse_args(args=args) options.parsed_cmds = [options] if not hasattr(options, 'remaining'): @@ -107,7 +104,7 @@ class ConsoleCommandParser(ConsoleBaseParser): class OptionParser(ConsoleBaseParser): def __init__(self, **kwargs): - super(OptionParser, self).__init__(**kwargs) + super().__init__(**kwargs) self.formatter = ConsoleColorFormatter() def exit(self, status=0, msg=None): @@ -118,9 +115,9 @@ class OptionParser(ConsoleBaseParser): def error(self, msg): """error(msg : string) - Print a usage message incorporating 'msg' to stderr and exit. - If you override this in a subclass, it should not return -- it - should either exit or raise an exception. + Print a usage message incorporating 'msg' to stderr and exit. + If you override this in a subclass, it should not return -- it + should either exit or raise an exception. """ raise OptionParserError(msg) @@ -139,5 +136,5 @@ class OptionParser(ConsoleBaseParser): def format_help(self): """Return help formatted with colors.""" - help_str = super(OptionParser, self).format_help() + help_str = super().format_help() return self.formatter.format_colors(help_str) |