1 Commits

Author SHA1 Message Date
Kenneth Reitz 53ec4c2e09 Merge branch 'develop' 2011-09-24 14:38:05 -04:00
16 changed files with 32 additions and 71 deletions
-1
View File
@@ -2,4 +2,3 @@
MANIFEST
*.pyc
.tox
build/
-1
View File
@@ -16,4 +16,3 @@ Patches and Suggestions
- Will Thames
- Greg Haskins
- Miguel Araujo <maraujop>
- takluyver
-5
View File
@@ -1,11 +1,6 @@
History
-------
0.3.0
+++++
* Python 3 support!
0.2.4
+++++
+3 -3
View File
@@ -19,11 +19,11 @@ from .pipes import piped_in
__title__ = 'clint'
__version__ = '0.3.0'
__build__ = 0x000300
__version__ = '0.2.5'
__build__ = 0x000205
__author__ = 'Kenneth Reitz'
__license__ = 'ISC'
__copyright__ = 'Copyright 2012 Kenneth Reitz'
__copyright__ = 'Copyright 2011 Kenneth Reitz'
__docformat__ = 'restructuredtext'
+1 -5
View File
@@ -14,11 +14,7 @@ from __future__ import absolute_import
import os
from sys import argv
try:
from collections import OrderedDict
except ImportError:
from .packages.ordereddict import OrderedDict
from .packages.ordereddict import OrderedDict
from .utils import expand_path, is_collection
__all__ = ('Args', )
+6 -12
View File
@@ -7,18 +7,12 @@ clint.eng
This module provides English language string helpers.
"""
from __future__ import print_function
MORON_MODE = False
COMMA = ','
CONJUNCTION = 'and'
SPACE = ' '
try:
unicode
except NameError:
unicode = str
def join(l, conj=CONJUNCTION, im_a_moron=MORON_MODE, seperator=COMMA):
"""Joins lists of words. Oxford comma and all."""
@@ -47,9 +41,9 @@ def join(l, conj=CONJUNCTION, im_a_moron=MORON_MODE, seperator=COMMA):
return unicode(str().join(collector))
if __name__ == '__main__':
print(join(['blue', 'red', 'yellow'], conj='or', im_a_moron=True))
print(join(['blue', 'red', 'yellow'], conj='or'))
print(join(['blue', 'red'], conj='or'))
print(join(['blue', 'red'], conj='and'))
print(join(['blue'], conj='and'))
print(join(['blue', 'red', 'yellow', 'green', 'ello'], conj='and'))
print join(['blue', 'red', 'yellow'], conj='or', im_a_moron=True)
print join(['blue', 'red', 'yellow'], conj='or')
print join(['blue', 'red'], conj='or')
print join(['blue', 'red'], conj='and')
print join(['blue'], conj='and')
print join(['blue', 'red', 'yellow', 'green', 'ello'], conj='and')
+1 -1
View File
@@ -115,7 +115,7 @@ class AppDir(object):
remove(fn)
else:
removedirs(fn)
except OSError as why:
except OSError, why:
if why.errno == errno.ENOENT:
pass
else:
+1 -1
View File
@@ -12,4 +12,4 @@ This module provides the text output helper system.
from . import colored
from . import progress
from .core import *
from core import *
+5 -13
View File
@@ -14,8 +14,6 @@ from __future__ import absolute_import
import re
import sys
PY3 = sys.version_info[0] >= 3
from ..packages import colorama
__all__ = (
@@ -55,18 +53,12 @@ class ColoredString(object):
def __repr__(self):
return "<%s-string: '%s'>" % (self.color, self.s)
def __str__(self):
return self.__unicode__().encode('utf8')
def __unicode__(self):
return self.color_str
if PY3:
__str__ = __unicode__
else:
def __str__(self):
return unicode(self).encode('utf8')
def __iter__(self):
return iter(self.color_str)
def __add__(self, other):
return str(self.color_str) + str(other)
@@ -76,8 +68,8 @@ class ColoredString(object):
def __mul__(self, other):
return (self.color_str * other)
def split(self, sep=None):
return [self._new(s) for s in self.s.split(sep)]
def split(self, x=' '):
return map(self._new, self.s.split(x))
def _new(self, s):
return ColoredString(self.color, s)
+3 -4
View File
@@ -17,17 +17,16 @@ STREAM = sys.stderr
BAR_TEMPLATE = '%s[%s%s] %i/%i\r'
DOTS_CHAR = '.'
BAR_FILLED_CHAR = '#'
BAR_EMPTY_CHAR = ' '
def bar(it, label='', width=32, hide=False, empty_char=BAR_EMPTY_CHAR, filled_char=BAR_FILLED_CHAR):
def bar(it, label='', width=32, hide=False, empty_char='-', filled_char='='):
"""Progress iterator. Wrap your iterables with it."""
def _show(_i):
x = int(width*_i/count)
if not hide:
STREAM.write(BAR_TEMPLATE % (
label, filled_char*x, empty_char*(width-x), _i, count))
label, bar_filled_char*x, bar_empty_char*(width-x), _i, count))
STREAM.flush()
count = len(it)
+1 -5
View File
@@ -16,10 +16,6 @@ import os.path
from os import makedirs
from glob import glob
try:
basestring
except NameError:
basestring = str
def expand_path(path):
"""Expands directories and globs in given path."""
@@ -53,7 +49,7 @@ def mkdir_p(path):
"""Emulates `mkdir -p` behavior."""
try:
makedirs(path)
except OSError as exc: # Python >2.5
except OSError, exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else:
+1 -3
View File
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import os
@@ -15,4 +13,4 @@ text = 'THIS TEXT IS COLORED %s!'
if __name__ == '__main__':
for color in colored.COLORS:
print(getattr(colored, color)(text % color.upper()))
print getattr(colored, color)(text % color.upper())
+1 -1
View File
@@ -17,7 +17,7 @@ colors = [
colored.magenta('magenta')
]
colors = [str(cs) for cs in colors]
colors = map(str, colors)
puts('Smart:')
+5 -7
View File
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import os
@@ -15,16 +13,16 @@ resources.init('kennethreitz', 'clint')
lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
print('%s created.' % resources.user.path)
print '%s created.' % resources.user.path
resources.user.write('lorem.txt', lorem)
print('lorem.txt created')
print 'lorem.txt created'
assert resources.user.read('lorem.txt') == lorem
print('lorem.txt has correct contents')
print 'lorem.txt has correct contents'
resources.user.delete('lorem.txt')
print('lorem.txt deleted')
print 'lorem.txt deleted'
assert resources.user.read('lorem.txt') == None
print('lorem.txt deletion confirmed')
print 'lorem.txt deletion confirmed'
+2 -3
View File
@@ -19,6 +19,5 @@ if __name__ == '__main__':
col = 60
puts(columns([(colored.red('Column 1')), col], [(colored.green('Column Two')), None],
[(colored.magenta('Column III')), col]))
puts(columns(['hi there my name is kenneth and this is a columns', col], [lorem, None], ['kenneths', col]))
puts(columns([(colored.red('Column 1')), col], [(colored.green('Column Two')), None], [(colored.magenta('Column III')), col]))
puts(columns(['hi there my name is kenneth and this is a columns', col], [lorem, None], ['kenneths', col]))
+2 -6
View File
@@ -38,18 +38,14 @@ setup(
license='ISC',
classifiers=(
# 'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: OSI Approved :: ISC License (ISCL)',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Topic :: Terminals :: Terminal Emulators/X Terminals',
# 'Programming Language :: Python :: 3.0',
# 'Programming Language :: Python :: 3.1',
),
)