import os
import glob

# must *not* have trailing slash on directories
sources = [
        'hgroot/rgrp/work/nonfiction/adverts.txt',
        'hgroot/rgrp/code/bin',
        'hgroot/rgrp/work/open_knowledge',
        # 'svk/rgrp/work/econ/supervisions/2008.txt',
        # 'hgroot/rgrp/sysadmin/macosx/synclocal.py'
        'hgroot/rgrp/sysadmin/common/mutt/.muttrc',
        'hgroot/rgrp/sysadmin/common/vim/.vimrc',
            ]

pat = 'hgroot/rgrp/misc/*.txt'
sources += glob.glob(pat)

symlinks = []

def symlink(src, dest):
    print 'Symlinking %s to %s' % (src, dest)
    try:
        os.symlink(src, dest)
    except Exception, inst:
        print 'Error: ', inst

def symlink_here(fp):
    fn = os.path.basename(fp)
    symlink(fp, fn)

def do_sources():
    for fp in sources:
        symlink_here(fp)

def do_symlinks():
    for src, dest in symlinks:
        symlink(src, dest)

import optparse
if __name__ == '__main__':
    usage = '''%prog

Set up a new machine with standard symlinks.

NB: you must run this in the location where you wish the symlinks to appear.
    '''
    parser = optparse.OptionParser(usage)
    options, args = parser.parse_args()
    do_sources()


