mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 04:27:58 +01:00
utf-8 use in setup when editing files
This commit is contained in:
parent
a3ba93f508
commit
c83607c1d6
1 changed files with 14 additions and 14 deletions
28
setup.py
28
setup.py
|
@ -244,9 +244,9 @@ class Setup():
|
||||||
if mane:
|
if mane:
|
||||||
(fileout, filein) = (None, None)
|
(fileout, filein) = (None, None)
|
||||||
try:
|
try:
|
||||||
fileout = open('ponysay.install', 'w+')
|
fileout = open('ponysay.install', 'wb+')
|
||||||
filein = open('ponysay', 'r')
|
filein = open('ponysay', 'rb')
|
||||||
data = ''.join(filein.readlines())
|
data = filein.read().decode('utf-8', 'replace')
|
||||||
|
|
||||||
data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env)
|
data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env)
|
||||||
for sharedir in [item[0] for item in sharedirs]:
|
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('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]])
|
||||||
data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION))
|
data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION))
|
||||||
|
|
||||||
fileout.write(data)
|
fileout.write(data.encode('utf-8'))
|
||||||
finally:
|
finally:
|
||||||
if fileout is not None: fileout.close()
|
if fileout is not None: fileout.close()
|
||||||
if filein is not None: filein .close()
|
if filein is not None: filein .close()
|
||||||
|
@ -270,15 +270,15 @@ class Setup():
|
||||||
dest = src + '.install'
|
dest = src + '.install'
|
||||||
(fileout, filein) = (None, None)
|
(fileout, filein) = (None, None)
|
||||||
try:
|
try:
|
||||||
fileout = open(dest, 'w+')
|
fileout = open(dest, 'wb+')
|
||||||
filein = open(src, 'r')
|
filein = open(src, 'rb')
|
||||||
data = ''.join(filein.readlines())
|
data = filein.read().decode('utf-8', 'replace')
|
||||||
|
|
||||||
data = data.replace('\n.TH PONYSAY 0', '\n.TH PONYSAY ' + conf['man-section-ponysay'])
|
data = data.replace('\n.TH PONYSAY 0', '\n.TH PONYSAY ' + conf['man-section-ponysay'])
|
||||||
for section in [item[0] for item in mansections]:
|
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]))
|
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:
|
finally:
|
||||||
if fileout is not None: fileout.close()
|
if fileout is not None: fileout.close()
|
||||||
if filein is not None: filein .close()
|
if filein is not None: filein .close()
|
||||||
|
@ -308,9 +308,9 @@ class Setup():
|
||||||
dest = src + '.' + command
|
dest = src + '.' + command
|
||||||
(fileout, filein) = (None, None)
|
(fileout, filein) = (None, None)
|
||||||
try:
|
try:
|
||||||
fileout = open(dest, 'w+')
|
fileout = open(dest, 'wb+')
|
||||||
filein = open(src, 'r')
|
filein = open(src, 'rb')
|
||||||
data = ''.join(filein.readlines())
|
data = filein.read().decode('utf-8', 'replace')
|
||||||
|
|
||||||
data = data.replace('/usr/bin/ponysay', conf[command])
|
data = data.replace('/usr/bin/ponysay', conf[command])
|
||||||
data = data.replace('/ponysay', '\0')
|
data = data.replace('/ponysay', '\0')
|
||||||
|
@ -319,7 +319,7 @@ class Setup():
|
||||||
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
|
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
|
||||||
data = data.replace('\0', '/ponysay')
|
data = data.replace('\0', '/ponysay')
|
||||||
|
|
||||||
fileout.write(data)
|
fileout.write(data.encode('utf-8'))
|
||||||
finally:
|
finally:
|
||||||
if fileout is not None: fileout.close()
|
if fileout is not None: fileout.close()
|
||||||
if filein is not None: filein .close()
|
if filein is not None: filein .close()
|
||||||
|
@ -329,8 +329,8 @@ class Setup():
|
||||||
os.mkdir('quotes')
|
os.mkdir('quotes')
|
||||||
ponymap = None
|
ponymap = None
|
||||||
try:
|
try:
|
||||||
ponymap = open('ponyquotes/ponies', 'r')
|
ponymap = open('ponyquotes/ponies', 'rb')
|
||||||
ponies = [line.replace('\n', '') for line in ponymap.readlines()]
|
ponies = [line for line in ponymap.read().decode('utf-8', 'replace').split('\n')]
|
||||||
for _ponies in ponies:
|
for _ponies in ponies:
|
||||||
for pony in _ponies.split('+'):
|
for pony in _ponies.split('+'):
|
||||||
print('Generating quote files for \033[34m' + pony + '\033[39m')
|
print('Generating quote files for \033[34m' + pony + '\033[39m')
|
||||||
|
|
Loading…
Reference in a new issue