diff options
author | Jon Bernard <jbernard@tuxion.com> | 2014-07-11 14:34:37 -0400 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2014-07-11 14:47:14 -0400 |
commit | 9188de595ff2e6ee9f06469dd4d708510930eafa (patch) | |
tree | 86e9877347a51bf2e31d427264998208a0032c81 | |
parent | b8a9784d79ab3a0ddfe8a59908f767dda2dc5ea2 (diff) | |
download | dotfiles-9188de595ff2e6ee9f06469dd4d708510930eafa.tar.gz dotfiles-9188de595ff2e6ee9f06469dd4d708510930eafa.tar.bz2 dotfiles-9188de595ff2e6ee9f06469dd4d708510930eafa.zip |
Cleanup imports and move __version__ to __init__.py
-rwxr-xr-x | bin/dotfiles | 5 | ||||
-rw-r--r-- | dotfiles/__init__.py | 14 | ||||
-rw-r--r-- | dotfiles/cli.py | 9 | ||||
-rw-r--r-- | dotfiles/core.py | 9 | ||||
-rw-r--r-- | dotfiles/utils.py | 2 | ||||
-rw-r--r-- | setup.py | 14 | ||||
-rw-r--r-- | tests/test_basic.py | 28 |
7 files changed, 40 insertions, 41 deletions
diff --git a/bin/dotfiles b/bin/dotfiles index 5f4e1c9..39c95a5 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -13,7 +13,6 @@ if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'dotfiles')) sys.path.insert(0, PROJECT_ROOT_DIRECTORY) os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) -import dotfiles.cli - if __name__ == '__main__': - dotfiles.cli.main() + from dotfiles.cli import main + main() diff --git a/dotfiles/__init__.py b/dotfiles/__init__.py index 26cd367..71c9cd3 100644 --- a/dotfiles/__init__.py +++ b/dotfiles/__init__.py @@ -1,3 +1,15 @@ # -*- coding: utf-8 -*- +""" + dotfiles + ~~~~~~~~ -__all__ = ["core"] + Dotfiles is a tool to make managing your dotfile symlinks in $HOME easy, + allowing you to keep all your dotfiles in a single directory. Hosting is up + to you. You can use a VCS like git, Dropbox, or even rsync to distribute + your dotfiles repository across multiple hosts. + + :copyright: (c) 2011-2014 by Jon Bernard. + :license: ISC, see LICENSE.rst for more details. +""" + +__version__ = '0.6.3' diff --git a/dotfiles/cli.py b/dotfiles/cli.py index a071240..7b1669e 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -9,14 +9,15 @@ This module provides the CLI interface to dotfiles. from __future__ import absolute_import import os -from . import core try: import ConfigParser as configparser except ImportError: import configparser from optparse import OptionParser, OptionGroup -from dotfiles.utils import compare_path, realpath_expanduser +from .utils import compare_path, realpath_expanduser +from .core import Dotfiles +from . import __version__ defaults = { @@ -133,7 +134,7 @@ def parse_args(): (opts, args) = parser.parse_args() if opts.show_version: - print('dotfiles v%s' % core.__version__) + print('dotfiles v%s' % __version__) exit(0) if not opts.action: @@ -242,6 +243,6 @@ def main(): update_settings(repo_config_opts, 'externals') update_settings(repo_config_opts, 'packages') - dotfiles = core.Dotfiles(**settings) + dotfiles = Dotfiles(**settings) dispatch(dotfiles, cli_opts.action, cli_opts.force, args) diff --git a/dotfiles/core.py b/dotfiles/core.py index 7daf316..e3d4a9b 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -12,13 +12,8 @@ import os.path import shutil import fnmatch -from dotfiles.utils import realpath_expanduser, is_link_to -from dotfiles.compat import symlink - - -__version__ = '0.6.3' -__author__ = 'Jon Bernard' -__license__ = 'ISC' +from .utils import realpath_expanduser, is_link_to +from .compat import symlink class Dotfile(object): diff --git a/dotfiles/utils.py b/dotfiles/utils.py index 28f2212..fd5909f 100644 --- a/dotfiles/utils.py +++ b/dotfiles/utils.py @@ -4,7 +4,7 @@ Misc utility functions. import os.path -from dotfiles.compat import islink, realpath +from .compat import islink, realpath def compare_path(path1, path2): @@ -1,21 +1,13 @@ -import re -import ast +# -*- coding: utf-8 -*- from setuptools import setup - - -_version_re = re.compile(r'__version__\s+=\s+(.*)') - - -with open('dotfiles/core.py', 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) +from dotfiles import __version__ setup( name='dotfiles', + version=__version__, author='Jon Bernard', author_email='jbernard@tuxion.com', - version=version, url='https://github.com/jbernard/dotfiles', packages=['dotfiles'], description='Easily manage your dotfiles', diff --git a/tests/test_basic.py b/tests/test_basic.py index c5a2a9b..c347768 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -8,8 +8,8 @@ import shutil import tempfile import unittest -from dotfiles import core -from dotfiles import cli +from dotfiles.cli import dispatch +from dotfiles.core import Dotfiles from dotfiles.utils import is_link_to @@ -52,7 +52,7 @@ class DotfilesTestCase(unittest.TestCase): os.mkdir(os.path.join(self.homedir, '.lastpass')) externals = {'.lastpass': '/tmp'} - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals=externals, packages=[], dry_run=False) @@ -69,14 +69,14 @@ class DotfilesTestCase(unittest.TestCase): def sync(self, files=None, force=False): assert bool(force) dotfiles = MockDotfiles() - cli.dispatch(dotfiles, 'sync', True, []) + dispatch(dotfiles, 'sync', True, []) def test_move_repository(self): """Test the move() method for a Dotfiles repository.""" touch(os.path.join(self.repository, 'bashrc')) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], force=True, externals={}, packages=[], dry_run=False) @@ -121,7 +121,7 @@ class DotfilesTestCase(unittest.TestCase): os.path.join(self.homedir, '.vim'), os.path.join(self.homedir, 'vim')) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=[], dry_run=False) @@ -171,7 +171,7 @@ class DotfilesTestCase(unittest.TestCase): for original, symlink in all_repo_files: touch(os.path.join(self.repository, original)) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=ignore, externals={}, packages=[], dry_run=False) @@ -207,7 +207,7 @@ class DotfilesTestCase(unittest.TestCase): touch(path) # Create Dotfiles object - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['package'], dry_run=False) @@ -249,7 +249,7 @@ class DotfilesTestCase(unittest.TestCase): package_file = '.package/bar' # Create Dotfiles object - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['package'], dry_run=False) @@ -289,7 +289,7 @@ class DotfilesTestCase(unittest.TestCase): for dotfile, _ in repo_files: touch(os.path.join(self.repository, dotfile)) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=[], dry_run=False) @@ -317,7 +317,7 @@ class DotfilesTestCase(unittest.TestCase): touch(repo_file) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=[], dry_run=False) @@ -347,7 +347,7 @@ class DotfilesTestCase(unittest.TestCase): os.makedirs(package_dir) touch('%s/testfile' % package_dir) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['config'], dry_run=False, quiet=True) @@ -370,7 +370,7 @@ class DotfilesTestCase(unittest.TestCase): os.makedirs(package_dir) touch('%s/testfile' % package_dir) - dotfiles = core.Dotfiles( + dotfiles = Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['config'], dry_run=False) @@ -389,7 +389,7 @@ class DotfilesTestCase(unittest.TestCase): os.makedirs(package_dir) touch('%s/testfile' % package_dir) - dotfiles = core.Dotfiles(homedir=self.homedir, + dotfiles = Dotfiles(homedir=self.homedir, repository=self.repository, prefix='.', ignore=[], |