Sync: Fix home directory expansion.

This commit is contained in:
Artem Sapegin 2012-11-28 12:51:21 +04:00
parent 24d0b516d2
commit d2d60120f8

View File

@ -10,7 +10,7 @@ import os
import glob import glob
import shutil import shutil
SOURCE_DIR = './dotfiles/tilde' SOURCE_DIR = '~/dotfiles/tilde'
EXCLUDE = [] EXCLUDE = []
NO_DOT_PREFIX = [] NO_DOT_PREFIX = []
@ -29,13 +29,13 @@ def is_link_to(link, dest):
def main(): def main():
os.chdir(SOURCE_DIR) os.chdir(os.path.expanduser(SOURCE_DIR))
for filename in [file for file in glob.glob('*') if file not in EXCLUDE]: for filename in [file for file in glob.glob('*') if file not in EXCLUDE]:
dotfile = filename dotfile = filename
if filename not in NO_DOT_PREFIX: if filename not in NO_DOT_PREFIX:
dotfile = '.' + dotfile dotfile = '.' + dotfile
dotfile = os.path.join(os.path.expanduser('~'), os.path.splitext(dotfile)[0]) dotfile = os.path.join(os.path.expanduser('~'), os.path.splitext(dotfile)[0])
source = os.path.join(SOURCE_DIR, filename) source = os.path.join(SOURCE_DIR, filename).replace('~', '.')
# Check that we aren't overwriting anything # Check that we aren't overwriting anything
if os.path.lexists(dotfile): if os.path.lexists(dotfile):