#!/usr/bin/env python
import os
from os.path import expanduser

try:
    FileNotFoundError = FileNotFoundError
except:
    FileNotFoundError = OSError

def delete_if_exists(file):
    try:
        os.remove(file)
    except FileNotFoundError:
        pass

def create_symlink(source, destination):
    print('symlinking', source, 'to', destination)
    delete_if_exists(destination)
    os.symlink(source, destination)

home = expanduser("~") + '/'
config = os.getcwd() + '/configs/'
files = os.listdir('configs')

for file in files:
    create_symlink(config + file, home + file)
