Skip to content

Commit

Permalink
Merge b985bc5 into 73872d9
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchinWeb committed Apr 12, 2016
2 parents 73872d9 + b985bc5 commit ace2573
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions green/output.py
Expand Up @@ -6,6 +6,7 @@
import platform
import sys
import termstyle
from unidecode import unidecode

global debug_level
debug_level = 0
Expand Down Expand Up @@ -144,14 +145,16 @@ class GreenStream(object):

def __init__(self, stream, override_appveyor=False, disable_windows=False):
self.stream = stream
self.disable_windows = disable_windows
self.override_appveyor = override_appveyor
# Ironically, AppVeyor doesn't support windows win32 system calls for
# colors, but it WILL interpret posix ansi escape codes!
on_windows = platform.system() == 'Windows'
on_appveyor = os.environ.get('APPVEYOR', False)
self.on_windows = platform.system() == 'Windows'
self.on_appveyor = os.environ.get('APPVEYOR', False)

if (override_appveyor
or ((on_windows and not on_appveyor)
and not disable_windows)): # pragma: no cover
or ((self.on_windows and not self.on_appveyor)
and not self.disable_windows)): # pragma: no cover
self.stream = wrap_stream(self.stream, None, None, None, True)
self.closed = False

Expand All @@ -167,6 +170,10 @@ def writeln(self, text=''):
def write(self, text):
if type(text) == bytes:
text = text.decode('utf-8')
if (self.override_appveyor
or ((self.on_windows and not self.on_appveyor)
and not self.disable_windows)): # pragma: no cover
text = unidecode(text)
self.stream.write(text)


Expand Down
3 changes: 3 additions & 0 deletions green/test/test_windows.py
Expand Up @@ -23,3 +23,6 @@ def test_colorOutput(self):
self.assertTrue(issubclass(type(gs.stream),
colorama.ansitowin32.StreamWrapper))

def test_unicode_override(self):
pass

1 change: 1 addition & 0 deletions requirements.txt
@@ -1,3 +1,4 @@
colorama
mock
python-termstyle
unidecode
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -12,6 +12,7 @@
dependencies = [
'colorama',
'python-termstyle',
'unidecode',
]
if sys.version_info[0] == 2:
dependencies.append('mock')
Expand Down

0 comments on commit ace2573

Please sign in to comment.