summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2011-06-04 19:15:51 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2011-06-04 19:15:51 -0400
commitccf43894771bb2f422d326ae5a864641ae03be9a (patch)
treed86f8604e9a8daaa01822e07ec9212633dbae7a4
parentdd64afd0e3f4ee362471d5e77296eb9109f9e9d6 (diff)
parent173cf389d50a9d7b8c22eadb722ada2bbbad3ee5 (diff)
downloaddotfiles-0.2.0.tar.gz
dotfiles-0.2.0.tar.bz2
dotfiles-0.2.0.zip
Merge branch 'release/0.2.0'v0.2.0
-rw-r--r--README.rst24
-rw-r--r--contrib/dotfilesrc12
-rw-r--r--dotfiles/__init__.py2
-rw-r--r--dotfiles/cli.py40
-rw-r--r--dotfiles/core.py15
5 files changed, 76 insertions, 17 deletions
diff --git a/README.rst b/README.rst
index 6e71871..f8b9f9d 100644
--- a/README.rst
+++ b/README.rst
@@ -4,10 +4,10 @@ Dotfile management made easy
``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 left to you. Yes, I've seen `<http://dotfiles.org>`_ and I don't
-believe in that model. If you're advanced enough to need dotfile management,
-then you probably already know how you want to host them. Using whatever VCS
-you prefer, or even rsync, you can easily distribute your dotfiles repository
+Hosting is left to you. Yes, I've seen `<http://dotfiles.org>`_ but I don't
+like that model. If you're advanced enough to need dotfile management, then you
+probably already know how you want to host them. Using whatever VCS you
+prefer, or even rsync, you can easily distribute your dotfiles repository
across multiple hosts.
Installation
@@ -51,6 +51,22 @@ To make it available to all your hosts: ::
You get the idea.
+Configuration
+-------------
+
+You can choose to create a configuration file to store personal
+customizations. By default, ``dotfiles`` will look in ``~/.dotfilesrc``. An
+example configuration file might look like: ::
+
+ [dotfiles]
+ repository = ~/Dotfiles
+ ignore = [
+ '.git',
+ '.gitignore']
+ externals = {
+ '.bzr.log': '/dev/null',
+ '.uml': '/tmp'}
+
License
-------
diff --git a/contrib/dotfilesrc b/contrib/dotfilesrc
new file mode 100644
index 0000000..fe1de3e
--- /dev/null
+++ b/contrib/dotfilesrc
@@ -0,0 +1,12 @@
+[dotfiles]
+repository = ~/Dotfiles
+prefix =
+ignore = [
+ '.metadata',
+ '.git',
+ '.gitignore']
+externals = {
+ '.adobe': '/tmp',
+ '.bzr.log': '/dev/null',
+ '.macromedia': '/tmp',
+ '.uml': '/tmp'}
diff --git a/dotfiles/__init__.py b/dotfiles/__init__.py
index cc4a822..0390200 100644
--- a/dotfiles/__init__.py
+++ b/dotfiles/__init__.py
@@ -3,6 +3,6 @@
import cli
from core import *
-__version__ = '0.1.0'
+__version__ = '0.2.0'
__all__ = ['cli', 'core']
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index 910dcdc..fadca25 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -2,6 +2,7 @@
import os
from . import core
+import ConfigParser
from optparse import OptionParser, OptionGroup
@@ -13,23 +14,37 @@ def method_list(object):
def parse_args():
parser = OptionParser(usage="Usage: %prog ACTION [OPTION...] [FILE...]")
+ parser.set_defaults(config=os.path.expanduser("~/.dotfilesrc"))
parser.set_defaults(repo=os.path.expanduser("~/Dotfiles"))
+ parser.set_defaults(prefix='')
+ parser.set_defaults(ignore=[])
+ parser.set_defaults(externals={})
+
+ parser.add_option("-C", "--config", type="string", dest="config",
+ help="set configuration file location (default is ~/.dotfilesrc)")
+
parser.add_option("-R", "--repo", type="string", dest="repo",
help="set repository location (default is ~/Dotfiles)")
action_group = OptionGroup(parser, "Actions")
+
action_group.add_option("-a", "--add", action="store_const", dest="action",
const="add", help="add dotfile(s) to the repository")
+
action_group.add_option("-c", "--check", action="store_const",
dest="action", const="check", help="check dotfiles repository")
+
action_group.add_option("-l", "--list", action="store_const",
dest="action", const="list",
help="list currently managed dotfiles")
+
action_group.add_option("-r", "--remove", action="store_const",
dest="action", const="remove",
help="remove dotfile(s) from the repository")
+
action_group.add_option("-s", "--sync", action="store_const",
dest="action", const="sync", help="update dotfile symlinks")
+
parser.add_option_group(action_group)
(opts, args) = parser.parse_args()
@@ -47,5 +62,28 @@ def parse_args():
def main():
+
(opts, args) = parse_args()
- getattr(core.Dotfiles(location=opts.repo), opts.action)(files=args)
+
+ config_defaults = {
+ 'repository': opts.repo,
+ 'prefix': opts.prefix,
+ 'ignore': opts.ignore,
+ 'externals': opts.externals}
+
+ parser = ConfigParser.SafeConfigParser(config_defaults)
+
+ if opts.config:
+
+ parser.read(opts.config)
+
+ if 'dotfiles' in parser.sections():
+ opts.repo = os.path.expanduser(parser.get('dotfiles', 'repository'))
+ opts.prefix = parser.get('dotfiles', 'prefix')
+ opts.ignore = eval(parser.get('dotfiles', 'ignore'))
+ opts.externals = eval(parser.get('dotfiles', 'externals'))
+
+ getattr(core.Dotfiles(location=opts.repo,
+ prefix=opts.prefix,
+ ignore=opts.ignore,
+ externals=opts.externals), opts.action)(files=args)
diff --git a/dotfiles/core.py b/dotfiles/core.py
index 3a60865..b04892f 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -47,23 +47,16 @@ class Dotfile(object):
class Dotfiles(object):
- IGNORES = ['.metadata', '.git', '.gitignore']
-
- EXTRAS = {'adobe': '/tmp',
- 'bzr.log': '/dev/null',
- 'macromedia': '/tmp',
- 'uml': '/tmp'}
-
- def __init__(self, location):
+ def __init__(self, location, prefix, ignore, externals):
self.location = location
self.dotfiles = []
contents = [x for x in os.listdir(self.location)
- if x not in Dotfiles.IGNORES]
+ if x not in ignore]
for file in contents:
self.dotfiles.append(Dotfile(file,
os.path.join(self.location, file)))
- for file in self.EXTRAS.keys():
- self.dotfiles.append(Dotfile(file, self.EXTRAS[file]))
+ for file in externals.keys():
+ self.dotfiles.append(Dotfile(file, externals[file]))
def list(self, **kwargs):
for dotfile in sorted(self.dotfiles,