Skip to content

Commit edec8c4

Browse files
authored
Merge pull request #203 from skogsbaer/sw/colors
Sw/colors
2 parents 4a4b203 + 726e5ef commit edec8c4

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Write Your Python Program - CHANGELOG
22

3+
* 2.2.2 (2026-04-03)
4+
* Fixed package hiding bug
35
* 2.2.1 (2026-03-26)
46
* Functionality for running standard unit tests
57
* 2.2.0 (2026-03-17)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Write Your Python Program!",
44
"description": "A user friendly python environment for beginners",
55
"license": "See license in LICENSE",
6-
"version": "2.2.1",
6+
"version": "2.2.2",
77
"publisher": "StefanWehr",
88
"icon": "icon.png",
99
"engines": {

python/code/wypp/ansi.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import re
2+
import sys
3+
import os
24

35
RESET = "\u001b[0;0m"
46
BOLD = "\u001b[1m"
@@ -21,8 +23,22 @@
2123
YELLOW = "\u001b[1;33m"
2224
WHITE = "\u001b[1;37m"
2325

26+
def useColors():
27+
if os.environ.get("WYPP_FORCE_COLORS") == "True":
28+
return True
29+
if "NO_COLOR" in os.environ:
30+
return False
31+
if not sys.stdout.isatty():
32+
return False
33+
if os.environ.get("TERM") == "dumb":
34+
return False
35+
return True
36+
2437
def color(s, color):
25-
return color + s + RESET
38+
if useColors():
39+
return color + s + RESET
40+
else:
41+
return s
2642

2743
def green(s):
2844
return color(s, GREEN + BOLD)

python/fileTestsLib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def _runTest(testFile: str,
253253
env = os.environ.copy()
254254
env['PYTHONPATH'] = os.pathsep.join([os.path.join(ctx.opts.baseDir, 'code')] + pythonPath)
255255
env['WYPP_UNDER_TEST'] = 'True'
256+
env['WYPP_FORCE_COLORS'] = 'True'
256257
debug(' '.join(cmd))
257258
with open(actualStdoutFile, 'w') as stdoutFile, \
258259
open(actualStderrFile, 'w') as stderrFile:

0 commit comments

Comments
 (0)