diff options
author | Robin Schneider <ypid@riseup.net> | 2018-05-21 19:10:17 +0200 |
---|---|---|
committer | Robin Schneider <ypid@riseup.net> | 2020-01-03 22:35:13 +0100 |
commit | 138fdbc8d7f42bd54e0a1d0c07d5858b1055ea50 (patch) | |
tree | 75fdb0dfcb6458ac90e7930047b00d3870624fff /dotbot/context.py | |
parent | e38e021ab324ea676a285ac4667f1fba1469a6bf (diff) |
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.
Diffstat (limited to 'dotbot/context.py')
-rw-r--r-- | dotbot/context.py | 8 |
1 files changed, 6 insertions, 2 deletions
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 |