mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 07:23:48 +00:00
correctly handle new created dotfile and existing ones
This commit is contained in:
@@ -281,7 +281,7 @@ class Cfg:
|
||||
return False, self._get_unique_key(dotfile.dst)
|
||||
|
||||
def new(self, dotfile, profile, link=False):
|
||||
""" import new dotfile (key is to be changed) """
|
||||
""" import new dotfile (key will change) """
|
||||
|
||||
# keep it short
|
||||
home = os.path.expanduser('~')
|
||||
@@ -298,7 +298,7 @@ class Cfg:
|
||||
# already in it
|
||||
if profile in self.prodots and dotfile in self.prodots[profile]:
|
||||
self.log.err('\"{}\" already present'.format(dotfile.key))
|
||||
return False
|
||||
return False, dotfile
|
||||
|
||||
# add for this profile
|
||||
if profile not in self.prodots:
|
||||
@@ -308,7 +308,7 @@ class Cfg:
|
||||
ent = self.content[self.key_profiles][profile]
|
||||
if self.key_all not in ent[self.key_profiles_dots]:
|
||||
ent[self.key_profiles_dots].append(dotfile.key)
|
||||
return True
|
||||
return True, dotfile
|
||||
|
||||
# adding the dotfile
|
||||
dotfile.key = key
|
||||
@@ -329,7 +329,7 @@ class Cfg:
|
||||
# adding to global list
|
||||
self.dotfiles[dotfile.key] = dotfile
|
||||
|
||||
return True
|
||||
return True, dotfile
|
||||
|
||||
def get_dotfiles(self, profile):
|
||||
""" returns a list of dotfiles for a specific profile """
|
||||
|
||||
@@ -232,21 +232,18 @@ def importer(opts, conf, paths):
|
||||
LOG.err('\"{}\" does not exist, ignored !'.format(path))
|
||||
continue
|
||||
dst = path.rstrip(os.sep)
|
||||
key = dst.split(os.sep)[-1]
|
||||
if key == 'config':
|
||||
key = '_'.join(dst.split(os.sep)[-2:])
|
||||
key = key.lstrip('.').lower()
|
||||
if os.path.isdir(dst):
|
||||
key = 'd_{}'.format(key)
|
||||
else:
|
||||
key = 'f_{}'.format(key)
|
||||
src = dst
|
||||
if dst.startswith(home):
|
||||
src = dst[len(home):]
|
||||
src = src.lstrip('.' + os.sep)
|
||||
dotfile = Dotfile(key, dst, src)
|
||||
|
||||
# create a new dotfile
|
||||
dotfile = Dotfile('', dst, src)
|
||||
retconf, new_dotfile = conf.new(dotfile, opts['profile'], opts['link'])
|
||||
dotfile = new_dotfile
|
||||
|
||||
# prepare hierarchy for dotfile
|
||||
srcf = os.path.join(CUR, opts['dotpath'], src)
|
||||
retconf = conf.new(dotfile, opts['profile'], opts['link'])
|
||||
if not os.path.exists(srcf):
|
||||
cmd = ['mkdir', '-p', '{}'.format(os.path.dirname(srcf))]
|
||||
if opts['dry']:
|
||||
|
||||
Reference in New Issue
Block a user