mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 12:38:50 +00:00
Import only used functions
This commit is contained in:
@@ -19,7 +19,7 @@ from dotdrop.updater import Updater
|
||||
from dotdrop.comparator import Comparator
|
||||
from dotdrop.dotfile import Dotfile
|
||||
from dotdrop.config import Cfg
|
||||
import dotdrop.utils as dd
|
||||
from dotdrop.utils import get_tmpdir, remove, strip_home, run
|
||||
from dotdrop.linktypes import LinkTypes
|
||||
|
||||
LOG = Logger()
|
||||
@@ -92,7 +92,7 @@ def cmd_install(opts, conf, temporary=False, keys=[]):
|
||||
variables=opts['variables'], debug=opts['debug'])
|
||||
tmpdir = None
|
||||
if temporary:
|
||||
tmpdir = dd.get_tmpdir()
|
||||
tmpdir = get_tmpdir()
|
||||
inst = Installer(create=opts['create'], backup=opts['backup'],
|
||||
dry=opts['dry'], safe=opts['safe'],
|
||||
base=opts['dotpath'], workdir=opts['workdir'],
|
||||
@@ -123,7 +123,7 @@ def cmd_install(opts, conf, temporary=False, keys=[]):
|
||||
if tmp:
|
||||
tmp = os.path.join(opts['dotpath'], tmp)
|
||||
if os.path.exists(tmp):
|
||||
dd.remove(tmp)
|
||||
remove(tmp)
|
||||
if len(r) > 0:
|
||||
if Cfg.key_actions_post in dotfile.actions:
|
||||
actions = dotfile.actions[Cfg.key_actions_post]
|
||||
@@ -191,7 +191,7 @@ def cmd_compare(opts, conf, tmp, focus=[], ignore=[]):
|
||||
# clean tmp transformed dotfile if any
|
||||
tmpsrc = os.path.join(opts['dotpath'], tmpsrc)
|
||||
if os.path.exists(tmpsrc):
|
||||
dd.remove(tmpsrc)
|
||||
remove(tmpsrc)
|
||||
if diff == '':
|
||||
if opts['debug']:
|
||||
LOG.dbg('diffing \"{}\" VS \"{}\"'.format(dotfile.key,
|
||||
@@ -245,7 +245,7 @@ def cmd_importer(opts, conf, paths):
|
||||
continue
|
||||
dst = path.rstrip(os.sep)
|
||||
dst = os.path.abspath(dst)
|
||||
src = dd.strip_home(dst)
|
||||
src = strip_home(dst)
|
||||
strip = '.' + os.sep
|
||||
if opts['keepdot']:
|
||||
strip = os.sep
|
||||
@@ -264,7 +264,7 @@ def cmd_importer(opts, conf, paths):
|
||||
if opts['dry']:
|
||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||
else:
|
||||
r, _ = dd.run(cmd, raw=False, debug=opts['debug'], checkerr=True)
|
||||
r, _ = run(cmd, raw=False, debug=opts['debug'], checkerr=True)
|
||||
if not r:
|
||||
LOG.err('importing \"{}\" failed!'.format(path))
|
||||
ret = False
|
||||
@@ -275,13 +275,13 @@ def cmd_importer(opts, conf, paths):
|
||||
if linkit:
|
||||
LOG.dry('would symlink {} to {}'.format(srcf, dst))
|
||||
else:
|
||||
r, _ = dd.run(cmd, raw=False, debug=opts['debug'], checkerr=True)
|
||||
r, _ = run(cmd, raw=False, debug=opts['debug'], checkerr=True)
|
||||
if not r:
|
||||
LOG.err('importing \"{}\" failed!'.format(path))
|
||||
ret = False
|
||||
continue
|
||||
if linkit:
|
||||
dd.remove(dst)
|
||||
remove(dst)
|
||||
os.symlink(srcf, dst)
|
||||
retconf, dotfile = conf.new(dotfile, opts['profile'],
|
||||
link=linkit, debug=opts['debug'])
|
||||
@@ -402,7 +402,7 @@ def apply_trans(opts, dotfile):
|
||||
msg = 'transformation \"{}\" failed for {}'
|
||||
LOG.err(msg.format(trans.key, dotfile.key))
|
||||
if new_src and os.path.exists(new_src):
|
||||
dd.remove(new_src)
|
||||
remove(new_src)
|
||||
return None
|
||||
return new_src
|
||||
|
||||
@@ -471,12 +471,12 @@ def main():
|
||||
# compare local dotfiles with dotfiles stored in dotdrop
|
||||
if opts['debug']:
|
||||
LOG.dbg('running cmd: compare')
|
||||
tmp = dd.get_tmpdir()
|
||||
tmp = get_tmpdir()
|
||||
opts['dopts'] = args['--dopts']
|
||||
ret = cmd_compare(opts, conf, tmp, focus=args['--file'],
|
||||
ignore=args['--ignore'])
|
||||
# clean tmp directory
|
||||
dd.remove(tmp)
|
||||
remove(tmp)
|
||||
|
||||
elif args['import']:
|
||||
# import dotfile(s)
|
||||
|
||||
Reference in New Issue
Block a user