summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dotfiles/core.py9
-rwxr-xr-xtest_dotfiles.py4
2 files changed, 10 insertions, 3 deletions
diff --git a/dotfiles/core.py b/dotfiles/core.py
index c679039..ae79724 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -9,6 +9,7 @@ This module provides the basic functionality of dotfiles.
import os
import shutil
+import fnmatch
__version__ = '0.4.2'
@@ -83,7 +84,13 @@ class Dotfiles(object):
self.dotfiles = list()
- for dotfile in list(x for x in os.listdir(self.repo) if x not in self.ignore):
+ all_repofiles = os.listdir(self.repo)
+ repofiles_to_symlink = set(all_repofiles)
+
+ for pat in self.ignore:
+ repofiles_to_symlink.difference_update(fnmatch.filter(all_repofiles, pat))
+
+ for dotfile in repofiles_to_symlink:
self.dotfiles.append(Dotfile(dotfile[len(self.prefix):],
os.path.join(self.repo, dotfile), self.home))
diff --git a/test_dotfiles.py b/test_dotfiles.py
index d12b5b0..0284ba4 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -133,7 +133,7 @@ class DotfilesTestCase(unittest.TestCase):
.vimrc -> Dotfiles/vimrc
"""
- ignore = ['*.swp', '.py?', 'install.sh']
+ ignore = ['*.swp', '*.py?', 'install.sh']
all_repo_files = (
('myscript.py', '.myscript.py'),
@@ -162,7 +162,7 @@ class DotfilesTestCase(unittest.TestCase):
# exist in the home dir.
self.assertEqual(
sorted(os.listdir(self.home)),
- sorted([f[1] for f in all_dotfiles]))
+ sorted([f[1] for f in all_dotfiles] + ['Dotfiles']))
for original, symlink in all_dotfiles:
original_path = os.path.join(self.repo, original)