Skip to content

Commit 8133d0f

Browse files
authored
bin/check-test-version.py: streamline text padding (exercism#1498)
1 parent 6585f7e commit 8133d0f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bin/check-test-version.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ class bcolors:
5050
UNDERLINE = '\033[4m'
5151

5252

53+
def cjust(string, width, fillchar=' '):
54+
while len(string) < width:
55+
string = fillchar + string
56+
if len(string) >= width:
57+
break
58+
string += fillchar
59+
return string
60+
61+
5362
def verify_spec_location(path):
5463
with open(os.path.join(path, 'package.json')) as f:
5564
data = json.load(f)
@@ -172,9 +181,10 @@ def check_test_version(
172181
referenced = get_referenced_version(exercise)
173182
up_to_date = available == referenced
174183
if up_to_date:
175-
status, status_color = ' OK ', bcolors.OKGREEN
184+
status, status_color = 'OK', bcolors.OKGREEN
176185
else:
177186
status, status_color = 'NOT OK', bcolors.FAIL
187+
status = cjust(status, 8)
178188
if not no_color:
179189
status = status_color + status + bcolors.ENDC
180190
if not up_to_date or print_ok:
@@ -186,7 +196,7 @@ def check_test_version(
186196
if name_only:
187197
baseline = exercise
188198
else:
189-
baseline = '[ {} ] {}: {}{}{}'.format(
199+
baseline = '[{}] {}: {}{}{}'.format(
190200
status,
191201
exercise,
192202
referenced,

0 commit comments

Comments
 (0)