mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-06 00:53:04 +00:00
keep order of included profiles for #149
This commit is contained in:
@@ -14,7 +14,7 @@ from dotdrop.settings import Settings
|
||||
from dotdrop.logger import Logger
|
||||
from dotdrop.templategen import Templategen
|
||||
from dotdrop.linktypes import LinkTypes
|
||||
from dotdrop.utils import shell
|
||||
from dotdrop.utils import shell, uniq_list
|
||||
|
||||
|
||||
class CfgYaml:
|
||||
@@ -490,7 +490,10 @@ class CfgYaml:
|
||||
others.extend(self._rec_resolve_profile_include(i))
|
||||
current.extend(others)
|
||||
# unique them
|
||||
values[self.key_profiles_dotfiles] = list(set(current))
|
||||
values[self.key_profiles_dotfiles] = uniq_list(current)
|
||||
if self.debug:
|
||||
dfs = values[self.key_profiles_dotfiles]
|
||||
self.log.dbg('profile dfs after include: {}'.format(dfs))
|
||||
return values.get(self.key_profiles_dotfiles, [])
|
||||
|
||||
def _resolve_path(self, path):
|
||||
|
||||
@@ -95,7 +95,7 @@ class Comparator:
|
||||
# content is different
|
||||
funny = comp.diff_files
|
||||
funny.extend(comp.funny_files)
|
||||
funny = list(set(funny))
|
||||
funny = utils.uniq_list(funny)
|
||||
for i in funny:
|
||||
lfile = os.path.join(left, i)
|
||||
rfile = os.path.join(right, i)
|
||||
|
||||
@@ -15,7 +15,7 @@ from dotdrop.templategen import Templategen
|
||||
from dotdrop.installer import Installer
|
||||
from dotdrop.updater import Updater
|
||||
from dotdrop.comparator import Comparator
|
||||
from dotdrop.utils import get_tmpdir, remove, strip_home, run
|
||||
from dotdrop.utils import get_tmpdir, remove, strip_home, run, uniq_list
|
||||
from dotdrop.linktypes import LinkTypes
|
||||
|
||||
LOG = Logger()
|
||||
@@ -71,7 +71,8 @@ def cmd_install(o):
|
||||
dotfiles = o.dotfiles
|
||||
if o.install_keys:
|
||||
# filtered dotfiles to install
|
||||
dotfiles = [d for d in dotfiles if d.key in set(o.install_keys)]
|
||||
uniq = uniq_list(o.install_keys)
|
||||
dotfiles = [d for d in dotfiles if d.key in uniq]
|
||||
if not dotfiles:
|
||||
msg = 'no dotfile to install for this profile (\"{}\")'
|
||||
LOG.warn(msg.format(o.profile))
|
||||
@@ -388,7 +389,8 @@ def cmd_detail(o):
|
||||
dotfiles = o.dotfiles
|
||||
if o.detail_keys:
|
||||
# filtered dotfiles to install
|
||||
dotfiles = [d for d in dotfiles if d.key in set(o.details_keys)]
|
||||
uniq = uniq_list(o.details_keys)
|
||||
dotfiles = [d for d in dotfiles if d.key in uniq]
|
||||
LOG.emph('dotfiles details for profile \"{}\":\n'.format(o.profile))
|
||||
for d in dotfiles:
|
||||
_detail(o.dotpath, d)
|
||||
|
||||
@@ -130,3 +130,12 @@ def must_ignore(paths, ignores, debug=False):
|
||||
LOG.dbg('ignore \"{}\" match: {}'.format(i, p))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def uniq_list(a_list):
|
||||
"""unique elements of a list while preserving order"""
|
||||
new = []
|
||||
for a in a_list:
|
||||
if a not in new:
|
||||
new.append(a)
|
||||
return new
|
||||
|
||||
Reference in New Issue
Block a user