aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dotfiles/compat.py9
-rw-r--r--dotfiles/core.py2
-rw-r--r--tests/test_basic.py80
3 files changed, 47 insertions, 44 deletions
diff --git a/dotfiles/compat.py b/dotfiles/compat.py
index b4a5cf5..456b9c9 100644
--- a/dotfiles/compat.py
+++ b/dotfiles/compat.py
@@ -7,6 +7,9 @@ import os
import os.path
+def is_unicode(s):
+ return type(s) == unicode # noqa
+
if hasattr(os, 'symlink'):
symlink = os.symlink
islink = os.path.islink
@@ -67,7 +70,7 @@ else:
def CreateSymbolicLink(name, target, is_dir):
assert type(name) == type(target)
- if type(name) == unicode:
+ if is_unicode(name):
stat = CreateSymbolicLinkW(name, target, is_dir)
else:
stat = CreateSymbolicLinkA(name, target, is_dir)
@@ -82,7 +85,7 @@ else:
CreateSymbolicLink(name, target, 0)
def GetFileAttributes(path):
- if type(path) == unicode:
+ if is_unicode(path):
return GetFileAttributesW(path)
else:
return GetFileAttributesA(path)
@@ -117,7 +120,7 @@ else:
return None
def CreateFile(path, access, sharemode, creation, flags):
- if type(path) == unicode:
+ if is_unicode(path):
return _CreateFileW(path, access, sharemode, None, creation,
flags, None)
else:
diff --git a/dotfiles/core.py b/dotfiles/core.py
index eba9ef8..37115fe 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -150,7 +150,7 @@ class Dotfiles(object):
for pat in self.ignore:
repofiles_to_symlink.difference_update(
- fnmatch.filter(all_repofiles, pat))
+ fnmatch.filter(all_repofiles, pat))
for dotfile in repofiles_to_symlink:
pkg_path = os.path.join(sub_dir, dotfile)
diff --git a/tests/test_basic.py b/tests/test_basic.py
index a36b688..471e383 100644
--- a/tests/test_basic.py
+++ b/tests/test_basic.py
@@ -51,9 +51,9 @@ class DotfilesTestCase(unittest.TestCase):
externals = {'.lastpass': '/tmp'}
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals=externals, packages=[],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals=externals, packages=[],
+ dry_run=False)
dotfiles.sync(force=True)
@@ -81,16 +81,16 @@ class DotfilesTestCase(unittest.TestCase):
touch(os.path.join(self.repository, 'bashrc'))
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], force=True, externals={}, packages=[],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], force=True, externals={}, packages=[],
+ dry_run=False)
dotfiles.sync()
# Make sure sync() did the right thing.
self.assertPathEqual(
- os.path.join(self.homedir, '.bashrc'),
- os.path.join(self.repository, 'bashrc'))
+ os.path.join(self.homedir, '.bashrc'),
+ os.path.join(self.repository, 'bashrc'))
target = os.path.join(self.homedir, 'MyDotfiles')
@@ -98,8 +98,8 @@ class DotfilesTestCase(unittest.TestCase):
self.assertTrue(os.path.exists(os.path.join(target, 'bashrc')))
self.assertPathEqual(
- os.path.join(self.homedir, '.bashrc'),
- os.path.join(target, 'bashrc'))
+ os.path.join(self.homedir, '.bashrc'),
+ os.path.join(target, 'bashrc'))
def test_force_sync_directory_symlink(self):
"""Test a forced sync on a directory symlink.
@@ -122,19 +122,19 @@ class DotfilesTestCase(unittest.TestCase):
# Make sure the symlink points to the correct location.
self.assertPathEqual(
- os.path.join(self.homedir, '.vim'),
- os.path.join(self.homedir, 'vim'))
+ os.path.join(self.homedir, '.vim'),
+ os.path.join(self.homedir, 'vim'))
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=[], dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=[], dry_run=False)
dotfiles.sync(force=True)
# The symlink should now point to the directory in the repository.
self.assertPathEqual(
- os.path.join(self.homedir, '.vim'),
- os.path.join(self.repository, 'vim'))
+ os.path.join(self.homedir, '.vim'),
+ os.path.join(self.repository, 'vim'))
def test_glob_ignore_pattern(self):
""" Test that the use of glob pattern matching works in the ignores
@@ -178,9 +178,9 @@ class DotfilesTestCase(unittest.TestCase):
touch(os.path.join(self.repository, original))
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=ignore, externals={}, packages=[],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=ignore, externals={}, packages=[],
+ dry_run=False)
dotfiles.sync()
@@ -214,9 +214,9 @@ class DotfilesTestCase(unittest.TestCase):
# Create Dotfiles object
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=['package'],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=['package'],
+ dry_run=False)
# Create symlinks in homedir
dotfiles.sync()
@@ -256,9 +256,9 @@ class DotfilesTestCase(unittest.TestCase):
# Create Dotfiles object
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=['package'],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=['package'],
+ dry_run=False)
path = os.path.join(self.homedir, package_file)
dirname = os.path.dirname(path)
@@ -295,9 +295,9 @@ class DotfilesTestCase(unittest.TestCase):
touch(os.path.join(self.repository, dotfile))
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=[],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=[],
+ dry_run=False)
# sync only certain dotfiles
for dotfile, should_sync in repo_files:
@@ -322,9 +322,9 @@ class DotfilesTestCase(unittest.TestCase):
touch(repo_file)
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=[],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=[],
+ dry_run=False)
dotfiles.sync()
@@ -351,9 +351,9 @@ class DotfilesTestCase(unittest.TestCase):
touch('%s/testfile' % package_dir)
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=['config'],
- dry_run=False, quiet=True)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=['config'],
+ dry_run=False, quiet=True)
# This should fail, you should not be able to add dotfiles that are
# defined to be packages.
@@ -369,9 +369,9 @@ class DotfilesTestCase(unittest.TestCase):
touch(os.path.join(self.repository, dotfile))
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=[],
- dry_run=False, no_dot_prefix=True)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=[],
+ dry_run=False, no_dot_prefix=True)
dotfiles.sync()
@@ -395,9 +395,9 @@ class DotfilesTestCase(unittest.TestCase):
touch('%s/testfile' % package_dir)
dotfiles = Dotfiles(
- homedir=self.homedir, path=self.repository,
- prefix='', ignore=[], externals={}, packages=['config'],
- dry_run=False)
+ homedir=self.homedir, path=self.repository,
+ prefix='', ignore=[], externals={}, packages=['config'],
+ dry_run=False)
# This should succeed and the directory structure in the repository
# should be created since it didn't already exist.