From: Orakaro Date: Mon, 11 Aug 2014 14:28:29 +0000 (+0900) Subject: xrange in python 3 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=13e6b275faf7b7fbc869c4f7ed2baa20346b0ed5;p=rainbowstream.git xrange in python 3 --- diff --git a/docs/conf.py b/docs/conf.py index ac74b53..e483b83 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh' # built documents. # # The short X.Y version. -version = '0.7.2' +version = '0.7.3' # The full version, including alpha/beta/rc tags. -release = '0.7.2' +release = '0.7.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rainbowstream/c_image.py b/rainbowstream/c_image.py index 8bd9328..96cab29 100644 --- a/rainbowstream/c_image.py +++ b/rainbowstream/c_image.py @@ -1,6 +1,7 @@ from PIL import Image from os.path import join, dirname, getmtime, exists, expanduser from .config import * +from .py3patch import * import ctypes import sys @@ -49,9 +50,9 @@ def image_to_display(path, start=None, length=None): i = i.resize((width, height), Image.ANTIALIAS) height = min(height, c['IMAGE_MAX_HEIGHT']) - for y in range(height): + for y in xrange(height): sys.stdout.write(' ' * start) - for x in range(width): + for x in xrange(width): p = i.getpixel((x, y)) r, g, b = p[:3] pixel_print(rgb2short(r, g, b)) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index bae4106..b4f5883 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -235,7 +235,7 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]): tweet = text.split() # Replace url if expanded_url: - for index in range(len(expanded_url)): + for index in xrange(len(expanded_url)): tweet = lmap( lambda x: expanded_url[index] if x == url[index] diff --git a/rainbowstream/pure_image.py b/rainbowstream/pure_image.py index 0f0a377..8f027bd 100644 --- a/rainbowstream/pure_image.py +++ b/rainbowstream/pure_image.py @@ -1,6 +1,7 @@ from PIL import Image from functools import partial from .config import * +from .py3patch import * import sys import os @@ -313,7 +314,7 @@ def hex_to_rgb(value): """ value = value.lstrip('#') lv = len(value) - return tuple(int(value[i:i + lv / 3], 16) for i in range(0, lv, lv / 3)) + return tuple(int(value[i:i + lv / 3], 16) for i in xrange(0, lv, lv / 3)) def rgb_to_hex(rgb): diff --git a/rainbowstream/py3patch.py b/rainbowstream/py3patch.py index 153d10d..660bd0b 100644 --- a/rainbowstream/py3patch.py +++ b/rainbowstream/py3patch.py @@ -25,6 +25,7 @@ if sys.version[0] == "2": lmap = lambda f, a: map(f, a) unc = lambda x: x.decode('utf-8') else: + xrange = range raw_input = input lmap = lambda f, a: list(map(f, a)) unc = lambda x: x diff --git a/setup.py b/setup.py index df66bb7..2acfb82 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '0.7.2' +version = '0.7.3' # Require install_requires = [