mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 19:09:44 +00:00
create directory hierarchy even when not containing files
This commit is contained in:
@@ -249,7 +249,7 @@ def update(opts, conf, path):
|
||||
if opts['safe'] and not LOG.ask(msg):
|
||||
return False
|
||||
else:
|
||||
run(cmd, raw=False)
|
||||
run(cmd, raw=False, debug=opts['debug'])
|
||||
LOG.log('\"{}\" updated from \"{}\".'.format(src, path))
|
||||
return True
|
||||
|
||||
@@ -283,14 +283,14 @@ def importer(opts, conf, paths):
|
||||
if opts['dry']:
|
||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||
else:
|
||||
run(cmd, raw=False)
|
||||
run(cmd, raw=False, debug=opts['debug'])
|
||||
cmd = ['cp', '-R', '-L', dst, srcf]
|
||||
if opts['dry']:
|
||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||
if opts['link']:
|
||||
LOG.dry('would symlink {} to {}'.format(srcf, dst))
|
||||
else:
|
||||
run(cmd, raw=False)
|
||||
run(cmd, raw=False, debug=opts['debug'])
|
||||
if opts['link']:
|
||||
remove(dst)
|
||||
os.symlink(srcf, dst)
|
||||
|
||||
@@ -104,6 +104,8 @@ class Installer:
|
||||
def _handle_dir(self, templater, profile, src, dst):
|
||||
"""install src to dst when is a directory"""
|
||||
ret = []
|
||||
self._create_dirs(dst)
|
||||
# handle all files in dir
|
||||
for entry in os.listdir(src):
|
||||
f = os.path.join(src, entry)
|
||||
if not os.path.isdir(f):
|
||||
@@ -161,6 +163,9 @@ class Installer:
|
||||
return False
|
||||
if os.path.exists(directory):
|
||||
return True
|
||||
if self.dry:
|
||||
self.log.dry('would mkdir -p {}'.format(directory))
|
||||
return True
|
||||
self.log.dbg('mkdir -p {}'.format(directory))
|
||||
os.makedirs(directory)
|
||||
return os.path.exists(directory)
|
||||
|
||||
@@ -24,6 +24,7 @@ class Templategen:
|
||||
|
||||
def __init__(self, base='.', debug=False):
|
||||
self.base = base.rstrip(os.sep)
|
||||
self.debug = debug
|
||||
loader = FileSystemLoader(self.base)
|
||||
self.env = Environment(loader=loader,
|
||||
trim_blocks=True, lstrip_blocks=True,
|
||||
@@ -43,7 +44,8 @@ class Templategen:
|
||||
|
||||
def _handle_file(self, src, profile):
|
||||
"""generate the file content from template"""
|
||||
filetype = utils.run(['file', '-b', src], raw=False).strip()
|
||||
filetype = utils.run(['file', '-b', src], raw=False, debug=self.debug)
|
||||
filetype = filetype.strip()
|
||||
self.log.dbg('\"{}\" filetype: {}'.format(src, filetype))
|
||||
istext = 'text' in filetype
|
||||
self.log.dbg('\"{}\" is text: {}'.format(src, istext))
|
||||
|
||||
@@ -14,9 +14,13 @@ from shutil import rmtree
|
||||
# local import
|
||||
from dotdrop.logger import Logger
|
||||
|
||||
LOG = Logger()
|
||||
|
||||
def run(cmd, raw=True):
|
||||
|
||||
def run(cmd, raw=True, debug=False):
|
||||
"""run a command in the shell (expects a list)"""
|
||||
if debug:
|
||||
LOG.dbg('exec: {}'.format(' '.join(cmd)))
|
||||
p = subprocess.Popen(cmd, shell=False,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if raw:
|
||||
|
||||
Reference in New Issue
Block a user