1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 10:18:49 +00:00
Files
dotdrop/dotdrop/dotfile.py
2019-02-02 22:09:23 +01:00

47 lines
1.3 KiB
Python

"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2017, deadc0de6
represents a dotfile in dotdrop
"""
from dotdrop.linktypes import LinkTypes
class Dotfile:
def __init__(self, key, dst, src,
actions={}, trans_r=None, trans_w=None,
link=LinkTypes.NOLINK, cmpignore=[], noempty=False,
upignore=[]):
# key of dotfile in the config
self.key = key
# path where to install this dotfile
self.dst = dst
# path where this dotfile is stored in dotdrop
self.src = src
# if it is a link
self.link = link
# list of actions
self.actions = actions
# read transformation
self.trans_r = trans_r
# write transformation
self.trans_w = trans_w
# pattern to ignore when comparing
self.cmpignore = cmpignore
# do not deploy empty file
self.noempty = noempty
# pattern to ignore when updating
self.upignore = upignore
def __str__(self):
msg = 'key:\"{}\", src:\"{}\", dst:\"{}\", link:\"{}\"'
return msg.format(self.key, self.src, self.dst, self.link.name.lower())
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __hash__(self):
return hash(self.dst) ^ hash(self.src) ^ hash(self.key)