#!/usr/bin/python
import sys

from useless.base.path import path

from paella.installer.toolkit import InstallerTools

print "running config script for xemacs trait"

def get(key):
    if ':' not in key:
        key = 'xemacs:%s' % key
    return env.dereference(key)


it = InstallerTools()
env = it.env()

default = get('default_editor')
if default in ['True', 'true', 'Yes', 'yes']:
    print "setting xemacs21 to the default editor"
    cmd = ['update-alternatives', '--install', '/usr/bin/editor',
           'editor', '/usr/bin/xemacs21']
    priority = get('alternatives_priority')
    print "Using priority of", priority
    cmd.append(priority)
    it.chroot(cmd)
    
#print "skipping execution, not ready yet."
#sys.exit(0)

