fix align with no colors

This commit is contained in:
Dimitris Zlatanidis 2014-12-22 05:17:28 +02:00
parent 6aec383525
commit 3d60df923b
2 changed files with 17 additions and 15 deletions

View file

@ -95,16 +95,16 @@ if os.path.isfile("/etc/slpkg/slpkg.conf"):
if line.startswith("USE_COLORS"):
use_colors = line[11:].strip()
if use_colors == "on":
color = {
'RED': '\x1b[31m',
'GREEN': '\x1b[32m',
'YELLOW': '\x1b[33m',
'CYAN': '\x1b[36m',
'GREY': '\x1b[38;5;247m',
'ENDC': '\x1b[0m'
}
else:
color = {
'RED': '\x1b[31m',
'GREEN': '\x1b[32m',
'YELLOW': '\x1b[33m',
'CYAN': '\x1b[36m',
'GREY': '\x1b[38;5;247m',
'ENDC': '\x1b[0m'
}
if use_colors == "off":
color = {
'RED': '',
'GREEN': '',

View file

@ -55,13 +55,15 @@ class RepoList(object):
'Status'))
template(78)
for repo_id, repo_name in sorted(self.all_repos.iteritems()):
status = '{0}disabled{1}'.format(color['RED'], color['ENDC'])
status = 'disabled'
COLOR = color['RED']
if repo_id in repositories:
status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC'])
print(' {0}{1}{2}{3}{4:>17}'.format(
status = 'enabled'
COLOR = color['GREEN']
print(' {0}{1}{2}{3}{4}{5:>15}{6}'.format(
repo_id, ' ' * (17 - len(repo_id)),
repo_name, ' ' * (52 - len(repo_name)),
status))
repo_name, ' ' * (45 - len(repo_name)),
COLOR, status, color['ENDC']))
print("\nFor enable or disable repositories edit "
"'/etc/slpkg/slpkg.conf' file\n")
sys.exit(0)