mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 12:27:59 +01:00
code manipulation in build system
This commit is contained in:
parent
ae2bf97af0
commit
52ccbcdca7
2 changed files with 41 additions and 34 deletions
72
ponysay
72
ponysay
|
@ -33,14 +33,7 @@ from subprocess import Popen, PIPE
|
||||||
'''
|
'''
|
||||||
The version of ponysay
|
The version of ponysay
|
||||||
'''
|
'''
|
||||||
VERSION = 'dev'
|
VERSION = 'dev' # this line should not be edited, it is fixed by the build system
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
The directory where ponysay is installed, this is modified when building with make
|
|
||||||
'''
|
|
||||||
INSTALLDIR = '/usr'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -114,11 +107,11 @@ class Ponysay():
|
||||||
return
|
return
|
||||||
|
|
||||||
maplines = []
|
maplines = []
|
||||||
for sharedir in sharedirs:
|
for ucsmap in ucsmaps:
|
||||||
if os.path.isfile(sharedir + 'ucsmap'):
|
if os.path.isfile(ucsmap):
|
||||||
mapfile = None
|
mapfile = None
|
||||||
try:
|
try:
|
||||||
mapfile = open(sharedir + 'ucsmap', 'r')
|
mapfile = open(ucsmap, 'r')
|
||||||
maplines += [line.replace('\n', '') for line in mapfile.readlines()]
|
maplines += [line.replace('\n', '') for line in mapfile.readlines()]
|
||||||
finally:
|
finally:
|
||||||
if mapfile is not None:
|
if mapfile is not None:
|
||||||
|
@ -157,11 +150,11 @@ class Ponysay():
|
||||||
return
|
return
|
||||||
|
|
||||||
maplines = []
|
maplines = []
|
||||||
for sharedir in sharedirs:
|
for ucsmap in ucsmaps:
|
||||||
if os.path.isfile(sharedir + 'ucsmap'):
|
if os.path.isfile(ucsmap):
|
||||||
mapfile = None
|
mapfile = None
|
||||||
try:
|
try:
|
||||||
mapfile = open(sharedir + 'ucsmap', 'r')
|
mapfile = open(ucsmap, 'r')
|
||||||
maplines += [line.replace('\n', '') for line in mapfile.readlines()]
|
maplines += [line.replace('\n', '') for line in mapfile.readlines()]
|
||||||
finally:
|
finally:
|
||||||
if mapfile is not None:
|
if mapfile is not None:
|
||||||
|
@ -1635,56 +1628,67 @@ Whether KMS is used
|
||||||
usekms = Ponysay.isUsingKMS()
|
usekms = Ponysay.isUsingKMS()
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
Root share/ directories
|
|
||||||
'''
|
|
||||||
sharedirs = []
|
|
||||||
_sharedirs = [HOME + '/.local/share/ponysay/', INSTALLDIR + '/share/ponysay/']
|
|
||||||
for sharedir in _sharedirs:
|
|
||||||
if os.path.isdir(sharedir):
|
|
||||||
sharedirs.append(sharedir)
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS
|
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS
|
||||||
'''
|
'''
|
||||||
|
set = set()
|
||||||
ponydirs = []
|
ponydirs = []
|
||||||
if linuxvt and not usekms: _ponydirs = [d + 'ttyponies/' for d in sharedirs]
|
if linuxvt and not usekms: _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', '/usr/share/ponysay/ttyponies/']
|
||||||
else: _ponydirs = [d + 'ponies/' for d in sharedirs]
|
else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', '/usr/share/ponysay/ponies/']
|
||||||
for ponydir in _ponydirs:
|
for ponydir in _ponydirs:
|
||||||
if os.path.isdir(ponydir):
|
if os.path.isdir(ponydir) and (ponydir not in set):
|
||||||
ponydirs.append(ponydir)
|
ponydirs.append(ponydir)
|
||||||
|
set.add(ponydirs)
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The directories where pony files are stored, extrattyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS
|
The directories where pony files are stored, extrattyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS
|
||||||
'''
|
'''
|
||||||
|
set = set()
|
||||||
extraponydirs = []
|
extraponydirs = []
|
||||||
if linuxvt and not usekms: _extraponydirs = [d + 'extrattyponies/' for d in sharedirs]
|
if linuxvt and not usekms: _extraponydirs = [HOME + '/.local/share/ponysay/extrattyponies/', '/usr/share/ponysay/extrattyponies/']
|
||||||
else: _extraponydirs = [d + 'extraponies/' for d in sharedirs]
|
else: _extraponydirs = [HOME + '/.local/share/ponysay/extraponies/', '/usr/share/ponysay/extraponies/']
|
||||||
for extraponydir in _extraponydirs:
|
for extraponydir in _extraponydirs:
|
||||||
if os.path.isdir(extraponydir):
|
if os.path.isdir(extraponydir) and (extraponydir not in set):
|
||||||
extraponydirs.append(extraponydir)
|
extraponydirs.append(extraponydir)
|
||||||
|
set.add(extraponydirs)
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The directories where quotes files are stored
|
The directories where quotes files are stored
|
||||||
'''
|
'''
|
||||||
|
set = set()
|
||||||
quotedirs = []
|
quotedirs = []
|
||||||
_quotedirs = [d + 'quotes/' for d in sharedirs]
|
_quotedirs = [HOME + '/.local/share/ponysay/quotes/', '/usr/share/ponysay/quotes/']
|
||||||
for quotedir in _quotedirs:
|
for quotedir in _quotedirs:
|
||||||
if os.path.isdir(quotedir):
|
if os.path.isdir(quotedir) and (quotedir not in set):
|
||||||
quotedirs.append(quotedir)
|
quotedirs.append(quotedir)
|
||||||
|
set.add(quotedirs)
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The directories where balloon style files are stored
|
The directories where balloon style files are stored
|
||||||
'''
|
'''
|
||||||
|
set = set()
|
||||||
balloondirs = []
|
balloondirs = []
|
||||||
_balloondirs = [d + 'balloons/' for d in sharedirs]
|
_balloondirs = [HOME + '/.local/share/ponysay/balloons/', '/usr/share/ponysay/balloons/']
|
||||||
for balloondir in _balloondirs:
|
for balloondir in _balloondirs:
|
||||||
if os.path.isdir(balloondir):
|
if os.path.isdir(balloondir) and (balloondir not in set):
|
||||||
balloondirs.append(balloondir)
|
balloondirs.append(balloondir)
|
||||||
|
set.add(balloondir)
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
ucsmap files
|
||||||
|
'''
|
||||||
|
set = set()
|
||||||
|
ucsmaps = []
|
||||||
|
_ucsmaps = [HOME + '/.local/share/ponysay/ucsmap', '/usr/share/ponysay/ucsmap']
|
||||||
|
for ucsmap in _ucsmaps:
|
||||||
|
if os.path.isdir(ucsmap) and (ucsmap not in set):
|
||||||
|
ucsmaps.append(ucsmap)
|
||||||
|
set.add(ucsmap)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m'
|
usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m'
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -250,6 +250,9 @@ class Setup():
|
||||||
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]:
|
||||||
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
|
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
|
||||||
|
for sharefile in sharefiles:
|
||||||
|
data = data.replace('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]])
|
||||||
|
data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (VERSION))
|
||||||
|
|
||||||
fileout.write(data)
|
fileout.write(data)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in a new issue