blob: f0e3682367c6f71423f71f3f8d11b8c664a03943 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# vim: set filencoding=utf8
"""
Subversion Commands
@author: Mike Crute (mcrute@ag.com)
@organization: SoftGroup Interactive, Inc.
@date: April 20, 2010
"""
import os
import sys
from obalie.log import inject_logger
# Commands are relative to this directory by default
__dir__ = os.path.dirname(__file__)
def load_commands(from_path=__dir__, package=__name__):
commands = {}
for filename in os.listdir(from_path):
name = filename[:-len('.py')]
import_path = '.'.join([package, name])
mod = __import__(import_path, globals(), locals(), [name])
command_catalog = getattr(mod, 'COMMANDS', None)
if command_catalog:
commands.update(command_catalog)
continue
impl_name = "{0}Command".format(name.capitalize())
command_impl = getattr(mod, impl_name, None)
if command_impl:
commands[name] = command_impl
return commands
class BaseCommand(object):
@inject_logger
def __init__(self, client, logger=None):
self.client = client
self.logger = logger
|