Skip to content

Commit

Permalink
Set fallback series for non-unicode encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove committed Mar 13, 2020
1 parent 125631f commit 9329164
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions enlighten/_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import platform
import sys
import time

try:
Expand All @@ -31,6 +32,14 @@
else:
SERIES_STD = u' ▏▎▍▌▋▊▉█'

# Test for non-unicode terminals
try:
SERIES_STD.encode(sys.__stdout__.encoding)
except UnicodeEncodeError: # pragma: no cover(Non-unicode Terminal)
SERIES_STD = u' |'
except AttributeError: # pragma: no cover(Non-standard Terminal)
pass

COLORS = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white',
'bright_black', 'bright_red', 'bright_green', 'bright_yellow',
'bright_blue', 'bright_magenta', 'bright_cyan', 'bright_white')
Expand Down

0 comments on commit 9329164

Please sign in to comment.