Ticket #2097: console-additions-and-spelling-fix.patch

File console-additions-and-spelling-fix.patch, 14.8 KB (added by ReVoid, 13 years ago)
  • deluge/ui/console/commands/info.py

    diff --git a/deluge/ui/console/commands/info.py b/deluge/ui/console/commands/info.py
    index 8a7f6daf0bde8cc91e59f91d07fdd1901de733c6..ae3b39fe8859596b143620da63bb3d359acf30b7 100644
    a b class Command(BaseCommand):  
    9797
    9898    option_list = BaseCommand.option_list + (
    9999            make_option('-v', '--verbose', action='store_true', default=False, dest='verbose',
    100                         help='shows more information per torrent'),
     100                        help='Shows more information per torrent'),
     101            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     102                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
    101103            make_option('-i', '--id', action='store_true', default=False, dest='tid',
    102                         help='use internal id instead of torrent name'),
     104                        help='Use internal id instead of torrent name'),
    103105            make_option('-s', '--state', action='store', dest='state',
    104106                        help="Only retrieve torrents in state STATE. "
    105107                        "Allowable values are: %s "%(", ".join(states))),
    106108    )
    107109
    108     usage =  "Usage: info [-v | -i | -s <state>] [<torrent-id> [<torrent-id> ...]]\n"\
     110    usage =  "Usage: info [-v | -i | -I | -s <state>] [<torrent-id> [<torrent-id> ...]]\n"\
    109111             "       info -s <state> will show only torrents in state <state>\n"\
    110112             "       You can give the first few characters of a torrent-id to identify the torrent."
    111113
    def handle(self, *args, **options):  
    116118        # Compile a list of torrent_ids to request the status of
    117119        torrent_ids = []
    118120        for arg in args:
    119             torrent_ids.extend(self.console.match_torrent(arg))
     121            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    120122
    121123        if not args:
    122             torrent_ids.extend(self.console.match_torrent(""))
     124            torrent_ids.extend(self.console.match_torrent("", options['intense_match']))
    123125
    124126        def on_torrents_status(status):
    125127            # Print out the information for each torrent
    def on_torrents_status_fail(reason):  
    134136        if options["state"]:
    135137            if options["state"] not in states:
    136138                self.console.write("Invalid state: %s"%options["state"])
    137                 self.console.write("Allowble values are: %s."%(", ".join(states)))
     139                self.console.write("Allowable values are: %s."%(", ".join(states)))
    138140                return
    139141            else:
    140142                status_dict["state"] = options["state"]
  • deluge/ui/console/commands/move.py

    diff --git a/deluge/ui/console/commands/move.py b/deluge/ui/console/commands/move.py
    index 011031417ef5c25c71643656201e1cd20e20f726..36fb488a6ab7ddc4a7c8a434f33536b9653a26da 100644
    a b  
    3333#
    3434#
    3535
     36import os.path
     37from optparse import make_option
     38
    3639from deluge.ui.console.main import BaseCommand
    3740from deluge.ui.client import client
    3841import deluge.component as component
    3942
    40 import os.path
    41 
    42 
    4343class Command(BaseCommand):
    4444    """Move torrents' storage location"""
    45     usage = "Usage: move <torrent-id> [<torrent-id> ...] <path>"
     45    option_list = BaseCommand.option_list + (
     46            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     47                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
     48    )
     49    usage = "Usage: move [ -I ] <torrent-id> [<torrent-id> ...] <path>"
    4650
    4751    def handle(self, *args, **options):
    4852        self.console = component.get("ConsoleUI")
    def handle(self, *args, **options):  
    5963
    6064        ids = []
    6165        for i in args[:-1]:
    62             ids.extend(self.console.match_torrent(i))
     66            ids.extend(self.console.match_torrent(i, options['intense_match']))
    6367
    6468        names = []
    6569        for i in ids:
  • deluge/ui/console/commands/pause.py

    diff --git a/deluge/ui/console/commands/pause.py b/deluge/ui/console/commands/pause.py
    index 351027897caad95c1e2baff6fc1434cf0cda986d..d6ce844e9f416405e6bfd097bfd81644cf9adce5 100644
    a b  
    3333#    statement from all source files in the program, then also delete it here.
    3434#
    3535#
     36from optparse import make_option
     37
    3638from deluge.ui.console.main import BaseCommand
    3739from deluge.ui.client import client
    3840import deluge.ui.console.colors as colors
     
    4042
    4143class Command(BaseCommand):
    4244    """Pause a torrent"""
    43     usage = "Usage: pause [ * | <torrent-id> [<torrent-id> ...] ]"
     45    option_list = BaseCommand.option_list + (
     46            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     47                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
     48    )
     49    usage = "Usage: pause [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]"
    4450    def handle(self, *args, **options):
    4551        self.console = component.get("ConsoleUI")
    4652
    def handle(self, *args, **options):  
    5359
    5460        torrent_ids = []
    5561        for arg in args:
    56             torrent_ids.extend(self.console.match_torrent(arg))
     62            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    5763
    5864        if torrent_ids:
    5965            return client.core.pause_torrent(torrent_ids)
  • deluge/ui/console/commands/recheck.py

    diff --git a/deluge/ui/console/commands/recheck.py b/deluge/ui/console/commands/recheck.py
    index 2e9cc75f1cef576ab8339812035c3b8d4de43b73..72a6981873310e9a61827934ad1559422e83197f 100644
    a b  
    3232#    statement from all source files in the program, then also delete it here.
    3333#
    3434#
     35from optparse import make_option
     36
    3537from deluge.ui.console.main import BaseCommand
    3638from deluge.ui.client import client
    3739import deluge.ui.console.colors as colors
     
    3941
    4042class Command(BaseCommand):
    4143    """Forces a recheck of the torrent data"""
    42     usage = "Usage: recheck [ * | <torrent-id> [<torrent-id> ...] ]"
     44    option_list = BaseCommand.option_list + (
     45            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     46                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
     47    )
     48    usage = "Usage: recheck [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]"
    4349    def handle(self, *args, **options):
    4450        self.console = component.get("ConsoleUI")
    4551
    def handle(self, *args, **options):  
    4753            self.console.write(self.usage)
    4854            return
    4955        if len(args) > 0 and args[0].lower() == '*':
    50             client.core.force_recheck(self.console.match_torrent(""))
     56            client.core.force_recheck(self.console.match_torrent("", options['intense_match']))
    5157            return
    5258
    5359        torrent_ids = []
    5460        for arg in args:
    55             torrent_ids.extend(self.console.match_torrent(arg))
     61            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    5662
    5763        if torrent_ids:
    5864            return client.core.force_recheck(torrent_ids)
  • deluge/ui/console/commands/resume.py

    diff --git a/deluge/ui/console/commands/resume.py b/deluge/ui/console/commands/resume.py
    index 70cd6cbe87b49d4f5cebf4092afa878163bd6c1a..09a00000a376907241ca12dd719bb13cf57716d8 100644
    a b  
    3333#    statement from all source files in the program, then also delete it here.
    3434#
    3535#
     36from optparse import make_option
    3637
    3738from deluge.ui.console.main import BaseCommand
    3839from deluge.ui.client import client
     
    4142
    4243class Command(BaseCommand):
    4344    """Resume a torrent"""
    44     usage = "Usage: resume [ * | <torrent-id> [<torrent-id> ...] ]"
     45    option_list = BaseCommand.option_list + (
     46            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     47                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
     48    )
     49    usage = "Usage: resume [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]"
    4550    def handle(self, *args, **options):
    4651        self.console = component.get("ConsoleUI")
    4752
    def handle(self, *args, **options):  
    5459
    5560        torrent_ids = []
    5661        for arg in args:
    57             torrent_ids.extend(self.console.match_torrent(arg))
     62            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    5863
    5964        if torrent_ids:
    6065            return client.core.resume_torrent(torrent_ids)
  • deluge/ui/console/commands/rm.py

    diff --git a/deluge/ui/console/commands/rm.py b/deluge/ui/console/commands/rm.py
    index 378a78d5c29bf44fc80ddab8a4e4af36b4ac5f10..a5c8e730936a318f7f748e74dca86b606d24e09d 100644
    a b  
    3333#    statement from all source files in the program, then also delete it here.
    3434#
    3535#
     36from optparse import make_option
     37
    3638from deluge.ui.console.main import BaseCommand
    3739import deluge.ui.console.colors as colors
    3840from deluge.ui.client import client
    3941import deluge.component as component
    4042
    41 from optparse import make_option
    42 
    43 
    4443class Command(BaseCommand):
    4544    """Remove a torrent"""
    46     usage = "Usage: rm <torrent-id>"
    47     aliases = ['del']
    48 
    4945    option_list = BaseCommand.option_list + (
     46            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     47                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
    5048            make_option('--remove_data', action='store_true', default=False,
    5149                        help="remove the torrent's data"),
    5250    )
     51    usage = "Usage: rm [ -I ] <torrent-id>"
     52    aliases = ['del']
    5353
    5454    def handle(self, *args, **options):
    5555        self.console = component.get("ConsoleUI")
    def handle(self, *args, **options):  
    5858
    5959        torrent_ids = []
    6060        for arg in args:
    61             torrent_ids.extend(self.console.match_torrent(arg))
     61            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    6262
    6363        for torrent_id in torrent_ids:
    6464            client.core.remove_torrent(torrent_id, options['remove_data'])
  • deluge/ui/console/commands/update-tracker.py

    diff --git a/deluge/ui/console/commands/update-tracker.py b/deluge/ui/console/commands/update-tracker.py
    index a4aa880e122294a38c67285a9325325c352b4e22..bd6792c235fd818ab73ac83d70688bf12c0ff866 100644
    a b  
    3333#    statement from all source files in the program, then also delete it here.
    3434#
    3535#
     36from optparse import make_option
     37
    3638from deluge.ui.console.main import BaseCommand
    3739import deluge.ui.console.colors as colors
    3840from deluge.ui.client import client
    3941import deluge.component as component
    4042
    41 from optparse import make_option
    42 
    43 
    4443class Command(BaseCommand):
    4544    """Update tracker for torrent(s)"""
    46     usage = "Usage: update-tracker [ * | <torrent-id> [<torrent-id> ...] ]"
     45    option_list = BaseCommand.option_list + (
     46            make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match',
     47                        help='Consider torrents which have the pattern anywhere in the name a match(slower)'),
     48    )
     49    usage = "Usage: update-tracker [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]"
    4750    aliases = ['reannounce']
    4851
    4952    def handle(self, *args, **options):
    def handle(self, *args, **options):  
    5659           
    5760        torrent_ids = []
    5861        for arg in args:
    59             torrent_ids.extend(self.console.match_torrent(arg))
     62            torrent_ids.extend(self.console.match_torrent(arg, options['intense_match']))
    6063
    6164        client.core.force_reannounce(torrent_ids)
    6265
  • deluge/ui/console/main.py

    diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py
    index 9ec0279a44efc1a39d3b8dbe0e4ed37415101eaf..abaa814f0afcc926321ad3c9c6169763084ba420 100644
    a b def on_torrents_status(torrents):  
    293293            client.core.get_session_state().addCallback(on_session_state)
    294294
    295295           
    296     def match_torrent(self, string):
     296    def match_torrent(self, string, intense_match):
    297297        """
    298298        Returns a list of torrent_id matches for the string.  It will search both
    299299        torrent_ids and torrent names, but will only return torrent_ids.
    300300
    301301        :param string: str, the string to match on
     302        :param intense_match: bool, whether we want to match anywhere or just from beginning
    302303
    303304        :returns: list of matching torrent_ids. Will return an empty list if
    304305            no matches are found.
    305306
    306307        """
    307308        if self.interactive and isinstance(self.screen,deluge.ui.console.modes.legacy.Legacy):
    308             return self.screen.match_torrent(string)
     309            return self.screen.match_torrent(string, intense_match)
    309310        ret = []
    310311        string = string.decode(self.encoding)
    311         for tid, name in self.torrents:
    312             if tid.startswith(string) or name.startswith(string):
    313                 ret.append(tid)
     312        if intense_match:
     313            for tid, name in self.torrents:
     314                if tid.startswith(string) or string in name:
     315                    ret.append(tid)
     316        else:
     317            for tid, name in self.torrents:
     318                if tid.startswith(string) or name.startswith(string):
     319                    ret.append(tid)
    314320
    315321        return ret
    316322
  • deluge/ui/console/modes/legacy.py

    diff --git a/deluge/ui/console/modes/legacy.py b/deluge/ui/console/modes/legacy.py
    index c59654dda77e435cb4a4dde949ab58828efe1c1b..9331a720a12c8afc2d3f30a3e25c5996b37adc3e 100644
    a b def get_torrent_name(self, torrent_id):  
    578578
    579579        return None
    580580
    581     def match_torrent(self, string):
     581    def match_torrent(self, string, intense_match):
    582582        """
    583583        Returns a list of torrent_id matches for the string.  It will search both
    584584        torrent_ids and torrent names, but will only return torrent_ids.
    585585
    586586        :param string: str, the string to match on
     587        :param intense_match: bool, whether we want to match anywhere or just from beginning
    587588
    588589        :returns: list of matching torrent_ids. Will return an empty list if
    589590            no matches are found.
    590591
    591592        """
    592593        ret = []
    593         for tid, name in self.torrents:
    594             if tid.startswith(string) or name.startswith(string):
    595                 ret.append(tid)
     594        if intense_match:
     595            for tid, name in self.torrents:
     596                if tid.startswith(string) or string in name:
     597                    ret.append(tid)
     598        else:
     599            for tid, name in self.torrents:
     600                if tid.startswith(string) or name.startswith(string):
     601                    ret.append(tid)
    596602
    597603        return ret
    598604