aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-27 03:49:48 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-27 03:49:48 +0200
commitc83607c1d65c0acdb661726d916030c4da6c0e16 (patch)
tree275cd3e35a703279dd5a03a33e0393eeac1cf397 /setup.py
parenta3ba93f50889368c57730e5c238e90d4687a9980 (diff)
downloadponysay-c83607c1d65c0acdb661726d916030c4da6c0e16.tar.gz
ponysay-c83607c1d65c0acdb661726d916030c4da6c0e16.tar.bz2
ponysay-c83607c1d65c0acdb661726d916030c4da6c0e16.zip
utf-8 use in setup when editing files
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/setup.py b/setup.py
index 445ccc6..b15324c 100755
--- a/setup.py
+++ b/setup.py
@@ -244,9 +244,9 @@ class Setup():
if mane:
(fileout, filein) = (None, None)
try:
- fileout = open('ponysay.install', 'w+')
- filein = open('ponysay', 'r')
- data = ''.join(filein.readlines())
+ fileout = open('ponysay.install', 'wb+')
+ filein = open('ponysay', 'rb')
+ data = filein.read().decode('utf-8', 'replace')
data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env)
for sharedir in [item[0] for item in sharedirs]:
@@ -255,7 +255,7 @@ class Setup():
data = data.replace('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]])
data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION))
- fileout.write(data)
+ fileout.write(data.encode('utf-8'))
finally:
if fileout is not None: fileout.close()
if filein is not None: filein .close()
@@ -270,15 +270,15 @@ class Setup():
dest = src + '.install'
(fileout, filein) = (None, None)
try:
- fileout = open(dest, 'w+')
- filein = open(src, 'r')
- data = ''.join(filein.readlines())
+ fileout = open(dest, 'wb+')
+ filein = open(src, 'rb')
+ data = filein.read().decode('utf-8', 'replace')
data = data.replace('\n.TH PONYSAY 0', '\n.TH PONYSAY ' + conf['man-section-ponysay'])
for section in [item[0] for item in mansections]:
data = data.replace('\n.BR %s (0)' % (section), '\n.BR %s (%s)' % (section, conf['man-section-' + section]))
- fileout.write(data)
+ fileout.write(data.encode('utf-8'))
finally:
if fileout is not None: fileout.close()
if filein is not None: filein .close()
@@ -308,9 +308,9 @@ class Setup():
dest = src + '.' + command
(fileout, filein) = (None, None)
try:
- fileout = open(dest, 'w+')
- filein = open(src, 'r')
- data = ''.join(filein.readlines())
+ fileout = open(dest, 'wb+')
+ filein = open(src, 'rb')
+ data = filein.read().decode('utf-8', 'replace')
data = data.replace('/usr/bin/ponysay', conf[command])
data = data.replace('/ponysay', '\0')
@@ -319,7 +319,7 @@ class Setup():
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
data = data.replace('\0', '/ponysay')
- fileout.write(data)
+ fileout.write(data.encode('utf-8'))
finally:
if fileout is not None: fileout.close()
if filein is not None: filein .close()
@@ -329,8 +329,8 @@ class Setup():
os.mkdir('quotes')
ponymap = None
try:
- ponymap = open('ponyquotes/ponies', 'r')
- ponies = [line.replace('\n', '') for line in ponymap.readlines()]
+ ponymap = open('ponyquotes/ponies', 'rb')
+ ponies = [line for line in ponymap.read().decode('utf-8', 'replace').split('\n')]
for _ponies in ponies:
for pony in _ponies.split('+'):
print('Generating quote files for \033[34m' + pony + '\033[39m')