| OLD | NEW |
| 1 # Copyright (c) 2009 Google Inc. All rights reserved. | 1 # Copyright (c) 2009 Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 command = args[command_index] | 99 command = args[command_index] |
| 100 return (command, args[:command_index] + args[command_index + 1:]) | 100 return (command, args[:command_index] + args[command_index + 1:]) |
| 101 | 101 |
| 102 def command_by_name(self, command_name): | 102 def command_by_name(self, command_name): |
| 103 for command in self.commands: | 103 for command in self.commands: |
| 104 if command_name == command.name: | 104 if command_name == command.name: |
| 105 return command | 105 return command |
| 106 return None | 106 return None |
| 107 | 107 |
| 108 def path(self): | 108 def path(self): |
| 109 raise NotImplementedError, "subclasses must implement" | 109 raise NotImplementedError("subclasses must implement") |
| 110 | 110 |
| 111 def command_completed(self): | 111 def command_completed(self): |
| 112 pass | 112 pass |
| 113 | 113 |
| 114 def should_show_in_main_help(self, command): | 114 def should_show_in_main_help(self, command): |
| 115 return command.show_in_main_help | 115 return command.show_in_main_help |
| 116 | 116 |
| 117 def should_execute_command(self, command): | 117 def should_execute_command(self, command): |
| 118 return True | 118 return True |
| 119 | 119 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 (should_execute, failure_reason) = self.should_execute_command(command) | 142 (should_execute, failure_reason) = self.should_execute_command(command) |
| 143 if not should_execute: | 143 if not should_execute: |
| 144 _log.error(failure_reason) | 144 _log.error(failure_reason) |
| 145 return 0 # FIXME: Should this really be 0? | 145 return 0 # FIXME: Should this really be 0? |
| 146 | 146 |
| 147 while True: | 147 while True: |
| 148 try: | 148 try: |
| 149 result = command.check_arguments_and_execute(options, args, self
) | 149 result = command.check_arguments_and_execute(options, args, self
) |
| 150 break | 150 break |
| 151 except TryAgain, e: | 151 except TryAgain as e: |
| 152 pass | 152 pass |
| 153 | 153 |
| 154 self.command_completed() | 154 self.command_completed() |
| 155 return result | 155 return result |
| OLD | NEW |