aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Remco Wendt <remco@maykinmedia.nl> 2011-10-24 00:39:22 +0200
committerGravatar Remco Wendt <remco@maykinmedia.nl> 2011-10-24 00:39:22 +0200
commit92e7a8ead118311086217c983a6747287ec084ff (patch)
treedb9e8dffea1939bb80ff273461b29a7a946fcc90
parent1c9d0a6641863de75e6c218882dfcdce051c1471 (diff)
downloaddotfiles-92e7a8ead118311086217c983a6747287ec084ff.tar.gz
dotfiles-92e7a8ead118311086217c983a6747287ec084ff.tar.bz2
dotfiles-92e7a8ead118311086217c983a6747287ec084ff.zip
Added glob style pattern support for the ignore option
-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)