diff options
author | Anish Athalye <me@anishathalye.com> | 2016-11-23 14:13:00 -0500 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2016-11-23 14:13:00 -0500 |
commit | 847cb101d486319da882f958b1cb58b515cc6db2 (patch) | |
tree | c42dd92dab7dc01c74c97f80a42ad2c8e128378d /plugins | |
parent | 4468fff67a9e9d9f611d5dade4a9486e75dafa1c (diff) | |
parent | d2e20c77db3811d8d0ef640a743f8dcc85075fdc (diff) |
Merge branch 'casey/empty-source'
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/link.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/link.py b/plugins/link.py index 3c7b8d4..4b50320 100644 --- a/plugins/link.py +++ b/plugins/link.py @@ -33,9 +33,9 @@ class Link(dotbot.Plugin): force = source.get('force', force) relink = source.get('relink', relink) create = source.get('create', create) - path = source['path'] + path = self._default_source(destination, source.get('path')) else: - path = source + path = self._default_source(destination, source) path = os.path.expandvars(os.path.expanduser(path)) if not self._exists(os.path.join(self._context.base_directory(), path)): success = False @@ -53,6 +53,16 @@ class Link(dotbot.Plugin): self._log.error('Some links were not successfully set up') return success + def _default_source(self, destination, source): + if source is None: + basename = os.path.basename(destination) + if basename.startswith('.'): + return basename[1:] + else: + return basename + else: + return source + def _is_link(self, path): ''' Returns true if the path is a symbolic link. |