From 3d60df923b3f49c32fb8df545b2eeda13f988b7d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 22 Dec 2014 05:17:28 +0200 Subject: [PATCH] fix align with no colors --- slpkg/__metadata__.py | 20 ++++++++++---------- slpkg/repolist.py | 12 +++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index 78089e37..ea0ea3f2 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -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': '', diff --git a/slpkg/repolist.py b/slpkg/repolist.py index 248266c3..30424124 100644 --- a/slpkg/repolist.py +++ b/slpkg/repolist.py @@ -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)