Changeset View
Changeset View
Standalone View
Standalone View
pykolab/setup/components.py
Show All 11 Lines | |||||
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, | ||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
from six import string_types | |||||
import os | import os | ||||
import pykolab | import pykolab | ||||
from pykolab.constants import * | from pykolab.constants import * | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | for components_path, dirnames, filenames in os.walk(components_base_path): | ||||
exec("%s_%s_register()" % (module,component_name)) | exec("%s_%s_register()" % (module,component_name)) | ||||
def register(component_name, func, group=None, description=None, aliases=[], after=[], before=[]): | def register(component_name, func, group=None, description=None, aliases=[], after=[], before=[]): | ||||
if not group == None: | if not group == None: | ||||
component = "%s_%s" % (group,component_name) | component = "%s_%s" % (group,component_name) | ||||
else: | else: | ||||
component = component_name | component = component_name | ||||
if isinstance(aliases, basestring): | if isinstance(aliases, string_types): | ||||
aliases = [aliases] | aliases = [aliases] | ||||
if component in components: | if component in components: | ||||
log.fatal(_("Command '%s' already registered") % (component)) | log.fatal(_("Command '%s' already registered") % (component)) | ||||
sys.exit(1) | sys.exit(1) | ||||
if callable(func): | if callable(func): | ||||
if group == None: | if group == None: | ||||
Show All 31 Lines |