diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5e4e2c9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "2.6" + - "2.7" + +# command to install dependencies +install: + - pip install -r requirements.pip +# command to run tests +script: make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4a04397 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +all: install_deps test + +filename=couleur-`python -c 'import couleur;print couleur.version'`.tar.gz + +export PYTHONPATH:= ${PWD} +export FORCE_COULEUR:= true + +install_deps: + @pip install -r requirements.pip + +test: + @nosetests --verbosity=2 + +clean: + @printf "Cleaning up files that are already in .gitignore... " + @for pattern in `cat .gitignore`; do rm -rf $$pattern; find . -name "$$pattern" -exec rm -rf {} \;; done + @echo "OK!" + +release: clean test publish + @printf "Exporting to $(filename)... " + @tar czf $(filename) couleur setup.py README.md + @echo "DONE!" + +publish: + @python setup.py sdist register upload diff --git a/README.md b/README.md index 316eff4..85311c1 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,8 @@ You will need to install [nose](http://somethingaboutorange.com/mrl/projects/nos And run: user@machine:~/Projects$ git clone git://github.com/gabrielfalcao/couleur.git user@machine:~/Projects$ cd couleur - user@machine:~/Projects/couleur$ nosetests + user@machine:~/Projects$ pip install -r requirements.pip + user@machine:~/Projects/couleur$ make ## nomenclature diff --git a/couleur.py b/couleur.py index 95ce648..2a8077a 100644 --- a/couleur.py +++ b/couleur.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) <2010> Gabriel Falcão +# Copyright (C) <2010-2012> Gabriel Falcão # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -20,7 +20,8 @@ import sys import uuid import platform -__version__ = '0.3' +__version__ = '0.4.0' + from StringIO import StringIO @@ -34,10 +35,11 @@ for handle in [sys.stdout, sys.stderr]: else: SUPPORTS_ANSI = True -if os.getenv('SURE_NO_COLORS'): +if os.getenv('COULEUR_DISABLE'): SUPPORTS_ANSI = False -SUPPORTS_ANSI = False +if os.getenv('FORCE_COULEUR'): + SUPPORTS_ANSI = True def minify(string): @@ -213,20 +215,22 @@ _sep2 = '_and_' class Shell(object): - def __init__(self, indent=2, linebreak=False, bold=False, disabled=False): + def __init__(self, indent=2, linebreak=False, bold=False, + disabled=not SUPPORTS_ANSI): self._indentation_factor = indent self._indent = 0 self._linebreak = linebreak self._bold = bold self._in_format = False self._disabled = disabled - self._backcolors = backcolors() - self._forecolors = forecolors() - self._modifiers = modifiers() - if disabled or not SUPPORTS_ANSI: + if disabled: self._backcolors = empty() self._forecolors = empty() self._modifiers = empty() + else: + self._backcolors = backcolors() + self._forecolors = forecolors() + self._modifiers = modifiers() def indent(self): self._indent += self._indentation_factor diff --git a/requirements.pip b/requirements.pip new file mode 100644 index 0000000..2828450 --- /dev/null +++ b/requirements.pip @@ -0,0 +1,4 @@ +distribute==0.6.27 +nose==1.1.2 +sure==1.0.6 +wsgiref==0.1.2 diff --git a/setup.py b/setup.py index 6542cac..20d6c4e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# Copyright (C) <2010> Gabriel Falcão +# Copyright (C) <2010-2012> Gabriel Falcão # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -16,31 +16,21 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . from setuptools import setup -import sys - -extra = {} -if sys.version_info >= (3,0): - u = str - extra.update( use_2to3 = True ) -else: - u = lambda s: unicode(s, 'utf8') - +from couleur import __version__ setup(name='couleur', - version='0.3.1', - description='ANSI terminal tool for python, colored shell and other ' \ - 'handy fancy features', - author=u('Gabriel Falcão'), + version=__version__, + description=(u'ANSI terminal tool for python, colored shell and other ' + 'handy fancy features'), + author='Gabriel Falcao', author_email='gabriel@nacaolivre.org', url='http://github.com/gabrielfalcao/couleur', py_modules=['couleur'], - classifiers = [ + classifiers=[ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', "Operating System :: POSIX", 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', ], - **extra )