From 4758017d69be7f23b07be2eef3cbf53b253aed91 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Tue, 17 Jul 2018 11:23:26 +0200 Subject: [PATCH] ensure expanding user when using --files in compare --- dotdrop/dotdrop.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index cc06cba..cbfccba 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -153,6 +153,23 @@ def apply_trans(opts, dotfile): return new_src +def _select(selections, dotfiles): + ret = True + selected = [] + for selection in selections: + df = next( + (x for x in dotfiles + if os.path.expanduser(x.dst) == os.path.expanduser(selection)), + None + ) + if df: + selected.append(df) + else: + LOG.err('no dotfile matches \"{}\"'.format(selection)) + ret = False + return selected, ret + + def compare(opts, conf, tmp, focus=None): """compare dotfiles and return True if all identical""" dotfiles = conf.get_dotfiles(opts['profile']) @@ -169,14 +186,7 @@ def compare(opts, conf, tmp, focus=None): ret = True selected = dotfiles if focus: - selected = [] - for selection in focus.replace(' ', '').split(','): - df = next((x for x in dotfiles if x.dst == selection), None) - if df: - selected.append(df) - else: - LOG.err('no dotfile matches \"{}\"'.format(selection)) - ret = False + selected, ret = _select(focus.replace(' ', '').split(','), dotfiles) if len(selected) < 1: return ret