diff options
author | Mike Crute <mcrute@gmail.com> | 2010-04-21 00:16:16 -0400 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-04-21 00:16:16 -0400 |
commit | e74452aabeb77ab8ab8f50a350d77e4d9e6914a2 (patch) | |
tree | 08a8bcd262622ded9f2996d1d37c174661df4b63 /obalie/commands/__init__.py | |
parent | 5156d1d7635806a237bdf9857702068290fc6340 (diff) | |
download | obalie-e74452aabeb77ab8ab8f50a350d77e4d9e6914a2.tar.bz2 obalie-e74452aabeb77ab8ab8f50a350d77e4d9e6914a2.tar.xz obalie-e74452aabeb77ab8ab8f50a350d77e4d9e6914a2.zip |
Adding basic info command
Diffstat (limited to 'obalie/commands/__init__.py')
-rw-r--r-- | obalie/commands/__init__.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/obalie/commands/__init__.py b/obalie/commands/__init__.py index e69de29..f0e3682 100644 --- a/obalie/commands/__init__.py +++ b/obalie/commands/__init__.py | |||
@@ -0,0 +1,47 @@ | |||
1 | # vim: set filencoding=utf8 | ||
2 | """ | ||
3 | Subversion Commands | ||
4 | |||
5 | @author: Mike Crute (mcrute@ag.com) | ||
6 | @organization: SoftGroup Interactive, Inc. | ||
7 | @date: April 20, 2010 | ||
8 | """ | ||
9 | |||
10 | |||
11 | import os | ||
12 | import sys | ||
13 | from obalie.log import inject_logger | ||
14 | |||
15 | |||
16 | # Commands are relative to this directory by default | ||
17 | __dir__ = os.path.dirname(__file__) | ||
18 | |||
19 | |||
20 | def load_commands(from_path=__dir__, package=__name__): | ||
21 | commands = {} | ||
22 | |||
23 | for filename in os.listdir(from_path): | ||
24 | name = filename[:-len('.py')] | ||
25 | import_path = '.'.join([package, name]) | ||
26 | |||
27 | mod = __import__(import_path, globals(), locals(), [name]) | ||
28 | |||
29 | command_catalog = getattr(mod, 'COMMANDS', None) | ||
30 | if command_catalog: | ||
31 | commands.update(command_catalog) | ||
32 | continue | ||
33 | |||
34 | impl_name = "{0}Command".format(name.capitalize()) | ||
35 | command_impl = getattr(mod, impl_name, None) | ||
36 | if command_impl: | ||
37 | commands[name] = command_impl | ||
38 | |||
39 | return commands | ||
40 | |||
41 | |||
42 | class BaseCommand(object): | ||
43 | |||
44 | @inject_logger | ||
45 | def __init__(self, client, logger=None): | ||
46 | self.client = client | ||
47 | self.logger = logger | ||