mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 17:53:52 +00:00
Merge branch 'master' of https://github.com/deadc0de6/dotdrop
This commit is contained in:
@@ -43,6 +43,8 @@ class Comparator:
|
||||
|
||||
def _comp_dir(self, left, right, ignore):
|
||||
"""compare a directory"""
|
||||
if not os.path.exists(right):
|
||||
return ''
|
||||
if self._ignore([left, right], ignore):
|
||||
if self.debug:
|
||||
self.log.dbg('ignoring diff {} and {}'.format(left, right))
|
||||
|
||||
@@ -36,6 +36,8 @@ class Installer:
|
||||
def install(self, templater, src, dst):
|
||||
"""install the src to dst using a template"""
|
||||
src = os.path.join(self.base, os.path.expanduser(src))
|
||||
if not os.path.exists(src):
|
||||
self.log.err('source dotfile does not exist: {}'.format(src))
|
||||
dst = os.path.expanduser(dst)
|
||||
if self.totemp:
|
||||
dst = self._pivot_path(dst, self.totemp)
|
||||
@@ -52,6 +54,8 @@ class Installer:
|
||||
def link(self, templater, src, dst):
|
||||
"""set src as the link target of dst"""
|
||||
src = os.path.join(self.base, os.path.expanduser(src))
|
||||
if not os.path.exists(src):
|
||||
self.log.err('source dotfile does not exist: {}'.format(src))
|
||||
dst = os.path.expanduser(dst)
|
||||
if self.totemp:
|
||||
return self.install(templater, src, dst)
|
||||
|
||||
@@ -93,6 +93,8 @@ class Templategen:
|
||||
|
||||
def is_template(path):
|
||||
"""recursively check if any file is a template within path"""
|
||||
if not os.path.exists(path):
|
||||
return False
|
||||
if os.path.isfile(path):
|
||||
# is file
|
||||
return Templategen._is_template(path)
|
||||
@@ -112,8 +114,12 @@ class Templategen:
|
||||
"""test if file pointed by path is a template"""
|
||||
if not os.path.isfile(path):
|
||||
return False
|
||||
with open(path, 'r') as f:
|
||||
data = f.read()
|
||||
try:
|
||||
with open(path, 'r') as f:
|
||||
data = f.read()
|
||||
except UnicodeDecodeError:
|
||||
# is binary so surely no template
|
||||
return False
|
||||
markers = [BLOCK_START, VAR_START, COMMENT_START]
|
||||
for marker in markers:
|
||||
if marker in data:
|
||||
|
||||
Reference in New Issue
Block a user