#!/usr/bin/env python
"""
Create symlinks to ~/Library/Preferences/*.plist from a syncing
storage source (like Google Drive, Dropbox or Tresorit)
"""
import glob
import os

import symlinks

HOME = os.path.expanduser('~')
PREFERENCES = os.path.join(HOME, 'Library/Preferences')
SYNCED_FOLDER = os.path.join(HOME, 'Documents/app-settings')


def make_preferences_path(source):
    """Build the dotfile destination from the original path
    """
    filename = os.path.basename(source)
    return os.path.join(PREFERENCES, filename)

sources = glob.glob(os.path.join(SYNCED_FOLDER, '*.plist'))
destinations = [make_preferences_path(s) for s in sources]

symlinks.make(sources, destinations)
