# vim: set filencoding=utf8 """ Subversion Commands @author: Mike Crute (mcrute@gmail.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