This commit is contained in:
Mattias Andrée 2012-08-18 14:29:57 +02:00
parent ab986563ec
commit f14e7b6c06

View file

@ -18,28 +18,28 @@ from subprocess import Popen, PIPE
''' '''
The version of ponysay The version of ponysay
''' '''
version = "2.0-alpha" VERSION = "2.0-alpha"
''' '''
The directory where ponysay is installed, this is modified when building with make The directory where ponysay is installed, this is modified when building with make
''' '''
installdir = '/usr' INSTALLDIR = '/usr'
''' '''
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
''' '''
ponydirs = [] ponydirs = []
if os.environ['TERM'] == 'linux': _ponydirs = [installdir + '/share/ponysay/ttyponies/', os.environ['HOME'] + '/.local/share/ponysay/ttyponies/'] if os.environ['TERM'] == 'linux': _ponydirs = [INSTALLDIR + '/share/ponysay/ttyponies/', os.environ['HOME'] + '/.local/share/ponysay/ttyponies/']
else: _ponydirs = [installdir + '/share/ponysay/ponies/', os.environ['HOME'] + '/.local/share/ponysay/ponies/' ] else: _ponydirs = [INSTALLDIR + '/share/ponysay/ponies/', os.environ['HOME'] + '/.local/share/ponysay/ponies/' ]
for ponydir in _ponydirs: for ponydir in _ponydirs:
if os.path.isdir(ponydir): if os.path.isdir(ponydir):
ponydirs.append(ponydir) ponydirs.append(ponydir)
parser = argparse.ArgumentParser(description = 'Ponysay, like cowsay with ponies') parser = argparse.ArgumentParser(description = 'Ponysay, like cowsay with ponies')
parser.add_argument('-v', '--version', action = 'version', version='%s %s' % (__file__, version)) parser.add_argument('-v', '--version', action = 'version', version = '%s %s' % ("ponysay", VERSION))
parser.add_argument('-l', '--list', action = 'store_true', dest = 'list', help = 'list pony files') parser.add_argument('-l', '--list', action = 'store_true', dest = 'list', help = 'list pony files')
parser.add_argument('-f', '--pony', action = 'append', dest = 'pony', help = 'select a pony (either a file name or a pony name)') parser.add_argument('-f', '--pony', action = 'append', dest = 'pony', help = 'select a pony (either a file name or a pony name)')
parser.add_argument('message', nargs = '?', help = 'message to ponysay') parser.add_argument('message', nargs = '?', help = 'message to ponysay')
@ -72,7 +72,7 @@ class ponysay():
x = 0 x = 0
for pony in ponies: for pony in ponies:
print(pony + (" " * (width - len(pony))), end="") # Print ponyfilename print(pony + (" " * (width - len(pony))), end="") # Print ponyfilename
x = x + width x += width
if x > (termsize[1] - width): # If too wide, make new line if x > (termsize[1] - width): # If too wide, make new line
print(); print();
x = 0 x = 0