Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Python 3 compatibility changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsyencken committed Oct 26, 2014
1 parent ab360be commit 51b139e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions colorific/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def color_stream_st(istream=sys.stdin, save_palette=False, **kwargs):
try:
palette = extract_colors(filename, **kwargs)

except Exception, e:
print >> sys.stderr, filename, e
except Exception as e:
print(filename, e, file=sys.stderr)
continue

print_colors(filename, palette)
Expand All @@ -55,7 +55,7 @@ def color_stream_mt(istream=sys.stdin, n=config.N_PROCESSES, **kwargs):
lock = multiprocessing.Lock()

pool = [multiprocessing.Process(target=color_process, args=(queue, lock),
kwargs=kwargs) for i in xrange(n)]
kwargs=kwargs) for i in range(n)]
for p in pool:
p.start()

Expand All @@ -68,7 +68,7 @@ def color_stream_mt(istream=sys.stdin, n=config.N_PROCESSES, **kwargs):
if block:
queue.put(block)

for i in xrange(n):
for i in range(n):
queue.put(config.SENTINEL)

for p in pool:
Expand Down
8 changes: 7 additions & 1 deletion colorific/script.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
#
# script.py
# colorific
#

import sys
import optparse

Expand Down Expand Up @@ -90,7 +96,7 @@ def run(self):
max_colors=options.max_colors,
n_quantized=options.n_quantized)

except Exception, e: # TODO: it's too broad exception.
except Exception as e: # TODO: it's too broad exception.
print >> sys.stderr, filename, e
continue

Expand Down
16 changes: 5 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
Package information for colorific.
"""

import sys

# check for the supported Python version
version = tuple(sys.version_info[:2])
if version != (2, 7):
sys.stderr.write(
'colorific requires Python 2.7 (you have %d.%d)\n' % version)
sys.stderr.flush()
sys.exit(1)

import os.path
from setuptools import setup, find_packages

try:
from setuptools import setup
except ImportError:
from distutils.core import setup

PROJECT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__)))
README_PATH = os.path.join(PROJECT_DIR, 'README.rst')
Expand Down

0 comments on commit 51b139e

Please sign in to comment.