mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 07:09:18 +00:00
linting
This commit is contained in:
@@ -150,6 +150,26 @@ class Importer:
|
|||||||
self.log.sub('\"{}\" imported'.format(path))
|
self.log.sub('\"{}\" imported'.format(path))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
def _prepare_hier_when_exists(self, srcf, dst):
|
||||||
|
"""a dotfile in dotpath already exists at that spot"""
|
||||||
|
if not os.path.exists(srcf):
|
||||||
|
return True
|
||||||
|
if not self.safe:
|
||||||
|
return True
|
||||||
|
cmp = Comparator(debug=self.debug,
|
||||||
|
diff_cmd=self.diff_cmd)
|
||||||
|
diff = cmp.compare(srcf, dst)
|
||||||
|
if diff != '':
|
||||||
|
# files are different, dunno what to do
|
||||||
|
self.log.log('diff \"{}\" VS \"{}\"'.format(dst, srcf))
|
||||||
|
self.log.emph(diff)
|
||||||
|
# ask user
|
||||||
|
msg = 'Dotfile \"{}\" already exists, overwrite?'
|
||||||
|
if not self.log.ask(msg.format(srcf)):
|
||||||
|
return False
|
||||||
|
self.log.dbg('will overwrite existing file')
|
||||||
|
return True
|
||||||
|
|
||||||
def _prepare_hierarchy(self, src, dst):
|
def _prepare_hierarchy(self, src, dst):
|
||||||
"""prepare hierarchy for dotfile"""
|
"""prepare hierarchy for dotfile"""
|
||||||
srcf = os.path.join(self.dotpath, src)
|
srcf = os.path.join(self.dotpath, src)
|
||||||
@@ -157,21 +177,8 @@ class Importer:
|
|||||||
if self._ignore(srcf) or self._ignore(srcfd):
|
if self._ignore(srcf) or self._ignore(srcfd):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# a dotfile in dotpath already exists at that spot
|
if not self._prepare_hier_when_exists(srcf, dst):
|
||||||
if os.path.exists(srcf):
|
return False
|
||||||
if self.safe:
|
|
||||||
cmp = Comparator(debug=self.debug,
|
|
||||||
diff_cmd=self.diff_cmd)
|
|
||||||
diff = cmp.compare(srcf, dst)
|
|
||||||
if diff != '':
|
|
||||||
# files are different, dunno what to do
|
|
||||||
self.log.log('diff \"{}\" VS \"{}\"'.format(dst, srcf))
|
|
||||||
self.log.emph(diff)
|
|
||||||
# ask user
|
|
||||||
msg = 'Dotfile \"{}\" already exists, overwrite?'
|
|
||||||
if not self.log.ask(msg.format(srcf)):
|
|
||||||
return False
|
|
||||||
self.log.dbg('will overwrite existing file')
|
|
||||||
|
|
||||||
# create directory hierarchy
|
# create directory hierarchy
|
||||||
if self.dry:
|
if self.dry:
|
||||||
|
|||||||
Reference in New Issue
Block a user