mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 10:59:16 +00:00
Add link support to config file and dotfile
This commit is contained in:
@@ -18,6 +18,7 @@ class Cfg:
|
|||||||
key_dotpath = 'dotpath'
|
key_dotpath = 'dotpath'
|
||||||
key_dotfiles_src = 'src'
|
key_dotfiles_src = 'src'
|
||||||
key_dotfiles_dst = 'dst'
|
key_dotfiles_dst = 'dst'
|
||||||
|
key_dotfiles_link = 'link'
|
||||||
|
|
||||||
def __init__(self, cfgpath):
|
def __init__(self, cfgpath):
|
||||||
if not os.path.exists(cfgpath):
|
if not os.path.exists(cfgpath):
|
||||||
@@ -61,7 +62,9 @@ class Cfg:
|
|||||||
for k, v in self.content[self.key_dotfiles].items():
|
for k, v in self.content[self.key_dotfiles].items():
|
||||||
src = v[self.key_dotfiles_src]
|
src = v[self.key_dotfiles_src]
|
||||||
dst = v[self.key_dotfiles_dst]
|
dst = v[self.key_dotfiles_dst]
|
||||||
self.dotfiles[k] = Dotfile(k, dst, src)
|
link = v[self.key_dotfiles_link] if self.key_dotfiles_link in v
|
||||||
|
else False
|
||||||
|
self.dotfiles[k] = Dotfile(k, dst, src, link)
|
||||||
# contains a list of dotfiles defined for each profile
|
# contains a list of dotfiles defined for each profile
|
||||||
for k, v in self.profiles.items():
|
for k, v in self.profiles.items():
|
||||||
self.prodots[k] = []
|
self.prodots[k] = []
|
||||||
@@ -115,8 +118,7 @@ class Cfg:
|
|||||||
""" returns a list of dotfiles for a specific profile """
|
""" returns a list of dotfiles for a specific profile """
|
||||||
if profile not in self.prodots:
|
if profile not in self.prodots:
|
||||||
return []
|
return []
|
||||||
tmp = sorted(self.prodots[profile], key=lambda x: x.key, reverse=True)
|
return sorted(self.prodots[profile], key=lambda x: x.key, reverse=True)
|
||||||
return tmp
|
|
||||||
|
|
||||||
def get_profiles(self):
|
def get_profiles(self):
|
||||||
""" returns all defined profiles """
|
""" returns all defined profiles """
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ represents a dotfile in dotdrop
|
|||||||
|
|
||||||
class Dotfile:
|
class Dotfile:
|
||||||
|
|
||||||
def __init__(self, key, dst, src):
|
def __init__(self, key, dst, src, link=False):
|
||||||
# key of dotfile in the config
|
# key of dotfile in the config
|
||||||
self.key = key
|
self.key = key
|
||||||
# where to install this dotfile
|
# where to install this dotfile
|
||||||
self.dst = dst
|
self.dst = dst
|
||||||
# stored dotfile in dotdrop
|
# stored dotfile in dotdrop
|
||||||
self.src = src
|
self.src = src
|
||||||
|
# should be a link
|
||||||
|
self.link = link
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = 'key:%s, src: %s, dst: %s' % (self.key,
|
return 'key:%s, src: %s, dst: %s, link: %s' % (self.key, self.src,
|
||||||
self.src, self.dst)
|
self.dst, self.link)
|
||||||
return string
|
|
||||||
|
|||||||
Reference in New Issue
Block a user