You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
973 B
Python

2 months ago
from .host import host
from .linker import Linker
2 months ago
class Home:
2 months ago
resource_name = "home"
def __init__(self, label, section):
self.label = label or None
2 months ago
self.parse_files(section.get("files", ""))
def parse_files(self, text):
self.files = []
lines = [s for s in text.splitlines() if s]
for line in lines:
parts = line.split(">", 2)
if len(parts) == 1:
pair = (parts[0].strip(), parts[0].strip())
else:
pair = (parts[0].strip(), parts[1].strip())
self.files.append(pair)
def __repr__(self):
if self.label:
2 months ago
return f"<Home: {self.label}>"
return "<Home>"
def run(self):
linker = Linker(host.dotfiles_root, host.home)
for pair in self.files:
source_path = host.dotfiles_root / pair[0]
target_path = host.home / pair[1]
linker.link(source_path, target_path)