Changeset 925dcd
- Timestamp:
- 04/28/2009 01:15:12 AM (16 years ago)
- Branches:
- 2.0.x, develop, extjs4-port, master
- Children:
- 7b72d7
- Parents:
- d4cfeb
- Location:
- deluge/ui/console
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/console/commands/config.py
rd4cfeb r925dcd 135 135 client.core.set_config({key: val}).addCallback(on_set_config) 136 136 137 """ 138 def complete(self, text, *args): 139 keys = [] 140 def _on_get_config(config): 141 keys.extend(config.keys()) 142 client.get_config(_on_get_config) 143 client.force_call() 144 return [ k for k in keys if k.startswith(text) ] 145 146 def split(self, text): 147 return str.split(text)""" 137 def complete(self, text): 138 return [ k for k in component.get("CoreConfig").keys() if k.startswith(text) ] -
deluge/ui/console/commands/debug.py
rd4cfeb r925dcd 27 27 import deluge.ui.console.colors as colors 28 28 import deluge.log 29 import deluge.component as component 29 30 30 31 class Command(BaseCommand): … … 37 38 deluge.log.setLoggerLevel("error") 38 39 else: 39 co nsole.write("{!error!}%s" % usage)40 component.get("ConsoleUI").write("{!error!}%s" % usage) 40 41 41 # def complete(self, text, *args):42 # return [ x for x in ['on', 'off'] if x.startswith(text)]42 def complete(self, text): 43 return [x for x in ['on', 'off'] if x.startswith(text)] -
deluge/ui/console/commands/help.py
rd4cfeb r925dcd 55 55 self.console.write(" ") 56 56 self.console.write('For help on a specific command, use "<command> --help"') 57 58 def complete(self, line): 59 return [x for x in component.get("ConsoleUI")._commands if x.startswith(line)] -
deluge/ui/console/commands/info.py
rd4cfeb r925dcd 93 93 " You can give the first few characters of a torrent-id to identify the torrent." 94 94 95 96 95 def handle(self, *args, **options): 97 96 self.console = component.get("ConsoleUI") … … 198 197 199 198 self.console.write(s[:-1]) 199 200 def complete(self, line): 201 # We use the ConsoleUI torrent tab complete method 202 return component.get("ConsoleUI").tab_complete_torrent(line) -
deluge/ui/console/commands/pause.py
rd4cfeb r925dcd 47 47 if torrent_ids: 48 48 client.core.pause_torrent(torrent_ids) 49 50 def complete(self, line): 51 # We use the ConsoleUI torrent tab complete method 52 return component.get("ConsoleUI").tab_complete_torrent(line) -
deluge/ui/console/commands/resume.py
rd4cfeb r925dcd 47 47 if torrent_ids: 48 48 client.core.resume_torrent(torrent_ids) 49 50 def complete(self, line): 51 # We use the ConsoleUI torrent tab complete method 52 return component.get("ConsoleUI").tab_complete_torrent(line) -
deluge/ui/console/commands/rm.py
rd4cfeb r925dcd 51 51 52 52 client.core.remove_torrent(torrent_ids, options['remove_data']) 53 54 def complete(self, line): 55 # We use the ConsoleUI torrent tab complete method 56 return component.get("ConsoleUI").tab_complete_torrent(line) -
deluge/ui/console/main.py
rd4cfeb r925dcd 226 226 """ 227 227 Called when the user hits 'tab' and will autocomplete or show options. 228 If a command is already supplied in the line, this function will call the 229 complete method of the command. 228 230 229 231 :param line: str, the current input string … … 238 240 # command that needs to be completed. 239 241 if " " not in line: 240 if len(line) == 0: 241 # We only print these out if it's a second_hit 242 if second_hit: 243 # There is nothing in line so just print out all possible commands 244 # and return. 245 self.write(" ") 246 for cmd in self._commands: 247 self.write(cmd) 248 return ("", 0) 242 possible_matches = [] 249 243 # Iterate through the commands looking for ones that startwith the 250 244 # line. 251 possible_matches = []252 245 for cmd in self._commands: 253 246 if cmd.startswith(line): … … 255 248 256 249 line_prefix = "" 257 258 250 else: 259 # This isn't a command so treat it as a torrent_id or torrent name 260 name = line.split(" ")[-1] 261 if len(name) == 0: 262 # There is nothing in the string, so just display all possible options 263 if second_hit: 264 self.write(" ") 265 # Display all torrent_ids and torrent names 266 for torrent_id, name in self.torrents: 267 self.write(torrent_id) 268 self.write(name) 251 cmd = line.split(" ")[0] 252 if cmd in self._commands: 253 # Call the command's complete method to get 'er done 254 possible_matches = self._commands[cmd].complete(line.split(" ")[-1]) 255 line_prefix = " ".join(line.split(" ")[:-1]) + " " 256 else: 257 # This is a bogus command 269 258 return (line, cursor) 270 271 # Find all possible matches272 possible_matches = []273 for torrent_id, torrent_name in self.torrents:274 if torrent_id.startswith(name):275 possible_matches.append(torrent_id)276 elif torrent_name.startswith(name):277 possible_matches.append(torrent_name)278 279 # Set the line prefix that should be prepended to any input line match280 line_prefix = " ".join(line.split(" ")[:-1]) + " "281 259 282 260 # No matches, so just return what we got passed … … 293 271 # Only print these out if it's a second_hit 294 272 self.write(" ") 295 for cmdin possible_matches:296 self.write( cmd)273 for match in possible_matches: 274 self.write(match) 297 275 return (line, cursor) 276 277 def tab_complete_torrent(self, line): 278 """ 279 Completes torrent_ids or names. 280 281 :param line: str, the string to complete 282 283 :returns: list of matches 284 285 """ 286 287 possible_matches = [] 288 289 # Find all possible matches 290 for torrent_id, torrent_name in self.torrents: 291 if torrent_id.startswith(line): 292 possible_matches.append(torrent_id) 293 if torrent_name.startswith(line): 294 possible_matches.append(torrent_name) 295 296 return possible_matches 298 297 299 298 def get_torrent_name(self, torrent_id):
Note:
See TracChangeset
for help on using the changeset viewer.