From 138fdbc8d7f42bd54e0a1d0c07d5858b1055ea50 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Mon, 21 May 2018 19:10:17 +0200 Subject: Add 'canonicalize-path' option to link Dotbot had a hardcoded behaviour that the BASEDIR was always passed to os.path.realpath which "returns the canonical path of the specified filename, eliminating any symbolic links encountered in the path". This might not always be desirable so this commit makes it configurable. The use case where `canonicalize-path` comes in handy is the following: You want to provide dotfiles in the Filesystem Hierarchy Standard under `/usr/local/share/ypid_dotfiles/`. Now you want to provide `.config/dotfiles` as a default in `/etc/skel`. When you now pre-configure `/etc/skel` by running dotbot in it set has HOME, dotfiles will refer to `/usr/local/share/ypid_dotfiles/` and not `/etc/skel/.config/dotfiles` which does not look nice. This is related to but not the same as the `relative` parameter used with link commands. --- dotbot/context.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'dotbot/context.py') diff --git a/dotbot/context.py b/dotbot/context.py index b2dbd6c..8c42d47 100644 --- a/dotbot/context.py +++ b/dotbot/context.py @@ -1,4 +1,5 @@ import copy +import os class Context(object): ''' @@ -13,8 +14,11 @@ class Context(object): def set_base_directory(self, base_directory): self._base_directory = base_directory - def base_directory(self): - return self._base_directory + def base_directory(self, canonical_path=True): + base_directory = self._base_directory + if canonical_path: + base_directory = os.path.realpath(base_directory) + return base_directory def set_defaults(self, defaults): self._defaults = defaults -- cgit v1.2.3