diff options
Diffstat (limited to 'subcmds/__init__.py')
-rw-r--r-- | subcmds/__init__.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/subcmds/__init__.py b/subcmds/__init__.py index 27341038..051dda06 100644 --- a/subcmds/__init__.py +++ b/subcmds/__init__.py | |||
@@ -1,5 +1,3 @@ | |||
1 | # -*- coding:utf-8 -*- | ||
2 | # | ||
3 | # Copyright (C) 2008 The Android Open Source Project | 1 | # Copyright (C) 2008 The Android Open Source Project |
4 | # | 2 | # |
5 | # Licensed under the Apache License, Version 2.0 (the "License"); | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -16,6 +14,7 @@ | |||
16 | 14 | ||
17 | import os | 15 | import os |
18 | 16 | ||
17 | # A mapping of the subcommand name to the class that implements it. | ||
19 | all_commands = {} | 18 | all_commands = {} |
20 | 19 | ||
21 | my_dir = os.path.dirname(__file__) | 20 | my_dir = os.path.dirname(__file__) |
@@ -37,14 +36,14 @@ for py in os.listdir(my_dir): | |||
37 | ['%s' % name]) | 36 | ['%s' % name]) |
38 | mod = getattr(mod, name) | 37 | mod = getattr(mod, name) |
39 | try: | 38 | try: |
40 | cmd = getattr(mod, clsn)() | 39 | cmd = getattr(mod, clsn) |
41 | except AttributeError: | 40 | except AttributeError: |
42 | raise SyntaxError('%s/%s does not define class %s' % ( | 41 | raise SyntaxError('%s/%s does not define class %s' % ( |
43 | __name__, py, clsn)) | 42 | __name__, py, clsn)) |
44 | 43 | ||
45 | name = name.replace('_', '-') | 44 | name = name.replace('_', '-') |
46 | cmd.NAME = name | 45 | cmd.NAME = name |
47 | all_commands[name] = cmd | 46 | all_commands[name] = cmd |
48 | 47 | ||
49 | if 'help' in all_commands: | 48 | # Add 'branch' as an alias for 'branches'. |
50 | all_commands['help'].commands = all_commands | 49 | all_commands['branch'] = all_commands['branches'] |