mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 11:18:30 +00:00
refactor printing dotfiles
This commit is contained in:
@@ -408,9 +408,11 @@ def cmd_importer(o):
|
|||||||
|
|
||||||
def cmd_list_profiles(o):
|
def cmd_list_profiles(o):
|
||||||
"""list all profiles"""
|
"""list all profiles"""
|
||||||
LOG.log('Available profile(s):')
|
LOG.emph('Available profile(s):\n')
|
||||||
for p in o.profiles:
|
for p in o.profiles:
|
||||||
LOG.sub(p.key)
|
LOG.sub(p.key, end='')
|
||||||
|
LOG.log(' ({} dotfiles)'.format(len(p.dotfiles)))
|
||||||
|
#LOG.sub('{} ({} dotfile(s))'.format(p.key, len(p.dotfiles)))
|
||||||
LOG.log('')
|
LOG.log('')
|
||||||
|
|
||||||
|
|
||||||
@@ -422,15 +424,16 @@ def cmd_list_files(o):
|
|||||||
what = 'Dotfile(s)'
|
what = 'Dotfile(s)'
|
||||||
if o.files_templateonly:
|
if o.files_templateonly:
|
||||||
what = 'Template(s)'
|
what = 'Template(s)'
|
||||||
LOG.emph('{} for profile \"{}\"\n'.format(what, o.profile))
|
LOG.emph('{} for profile \"{}\":\n'.format(what, o.profile))
|
||||||
for dotfile in o.dotfiles:
|
for dotfile in o.dotfiles:
|
||||||
if o.files_templateonly:
|
if o.files_templateonly:
|
||||||
src = os.path.join(o.dotpath, dotfile.src)
|
src = os.path.join(o.dotpath, dotfile.src)
|
||||||
if not Templategen.is_template(src):
|
if not Templategen.is_template(src):
|
||||||
continue
|
continue
|
||||||
LOG.log('{} (src: \"{}\", link: {})'.format(dotfile.key, dotfile.src,
|
LOG.log('{}'.format(dotfile.key), bold=True)
|
||||||
dotfile.link.name.lower()))
|
LOG.sub('dst: {}'.format(dotfile.dst))
|
||||||
LOG.sub('{}'.format(dotfile.dst))
|
LOG.sub('src: {}'.format(dotfile.src))
|
||||||
|
LOG.sub('link: {}'.format(dotfile.link.name.lower()))
|
||||||
LOG.log('')
|
LOG.log('')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,15 +24,22 @@ class Logger:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def log(self, string, end='\n', pre=''):
|
def log(self, string, end='\n', pre='', bold=False):
|
||||||
cs = self._color(self.BLUE)
|
cs = self._color(self.BLUE)
|
||||||
ce = self._color(self.RESET)
|
ce = self._color(self.RESET)
|
||||||
sys.stdout.write('{}{}{}{}{}'.format(pre, cs, string, end, ce))
|
if bold:
|
||||||
|
bl = self._color(self.BOLD)
|
||||||
|
fmt = '{}{}{}{}{}{}{}'.format(pre, cs, bl,
|
||||||
|
string, ce,
|
||||||
|
end, ce)
|
||||||
|
else:
|
||||||
|
fmt = '{}{}{}{}{}'.format(pre, cs, string, end, ce)
|
||||||
|
sys.stdout.write(fmt)
|
||||||
|
|
||||||
def sub(self, string):
|
def sub(self, string, end='\n'):
|
||||||
cs = self._color(self.BLUE)
|
cs = self._color(self.BLUE)
|
||||||
ce = self._color(self.RESET)
|
ce = self._color(self.RESET)
|
||||||
sys.stdout.write('\t{}->{} {}\n'.format(cs, ce, string))
|
sys.stdout.write('\t{}->{} {}{}'.format(cs, ce, string, end))
|
||||||
|
|
||||||
def emph(self, string):
|
def emph(self, string):
|
||||||
cs = self._color(self.EMPH)
|
cs = self._color(self.EMPH)
|
||||||
|
|||||||
Reference in New Issue
Block a user