def compare(opts, conf, tmp): dotfiles = conf.get_dotfiles(opts['profile']) if dotfiles == []: LOG.err('no dotfiles defined for this profile (\"%s\")' % (str(opts['profile']))) return False t = Templategen(base=opts['dotpath']) inst = Installer(create=opts['create'], backup=opts['backup'], dry=opts['dry'], base=opts['dotpath'], quiet=True) for dotfile in dotfiles: LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst)) inst.compare(t, tmp, opts['profile'], dotfile.src, dotfile.dst) return len(dotfiles) > 0
def compare(opts, conf, tmp, focus=None): dotfiles = conf.get_dotfiles(opts['profile']) if dotfiles == []: LOG.err('no dotfiles defined for this profile (\"%s\")' % (str(opts['profile']))) return False t = Templategen(base=opts['dotpath']) inst = Installer(create=opts['create'], backup=opts['backup'], dry=opts['dry'], base=opts['dotpath'], quiet=opts['quiet']) # compare only specific files 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 \"%s\"' % (selection)) for dotfile in selected: same, diff = inst.compare(t, tmp, opts['profile'], dotfile.src, dotfile.dst) if same: if not opts['quiet']: LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst)) LOG.raw('same file') else: LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst)) LOG.emph(diff) return len(selected) > 0