Skip to content

Commit

Permalink
using termstyle instead of termcolor
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierverdier committed Aug 26, 2011
1 parent 7cc0374 commit a9725c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -44,4 +44,4 @@ Requirements
************

- Python v.2.6 (because of the new string formatting)
- ``termcolor`` (optional but strongly advised): to display results in colour
- ``termstyle`` (optional but strongly advised): to display results in colour
15 changes: 11 additions & 4 deletions pydflatex/typesetter.py
Expand Up @@ -114,14 +114,21 @@ class LaTeXLoggerColour(LaTeXLogger):
'info': {'attrs': ['bold']}
}

def styled(self, msg, colour):
return colored(msg, **self.colours[colour])
def styled(self, msg, style):
style_specs = self.colours[style]
color = style_specs.get('color')
styled = msg
if color:
styled = getattr(termstyle, style_specs['color'])(styled)
for attr in style_specs.get('attrs',[]):
styled = getattr(termstyle, attr)(styled)
return styled

try:
from termcolor import colored
import termstyle
except ImportError:
import warnings
warnings.warn('termcolor was not found: in black and white it will be')
warnings.warn('termstyle was not found: in black and white it will be')
LaTeXLoggerColour = LaTeXLogger

latex_logger = LaTeXLogger('pydflatex')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,2 +1,2 @@
termcolor
termstyle
nose

0 comments on commit a9725c5

Please sign in to comment.