mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-16 17:44:23 +01:00
fix ponysay-tool installation
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
7bbc0a0266
commit
298679fecf
3 changed files with 65 additions and 74 deletions
8
setup.py
8
setup.py
|
@ -558,17 +558,17 @@ class Setup():
|
||||||
if hasponies and os.path.isdir(sharedir):
|
if hasponies and os.path.isdir(sharedir):
|
||||||
for toolcommand in ('--dimensions', '--metadata'):
|
for toolcommand in ('--dimensions', '--metadata'):
|
||||||
if not self.free:
|
if not self.free:
|
||||||
print('%s, %s, %s' % ('./src/ponysay-tool.py', toolcommand, sharedir))
|
print('%s, %s, %s' % ('./src/ponysaytool.py', toolcommand, sharedir))
|
||||||
Popen(['./src/ponysay-tool.py', toolcommand, sharedir], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
Popen(['./src/ponysaytool.py', toolcommand, sharedir], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
||||||
else:
|
else:
|
||||||
params = ['./src/ponysay-tool.py', toolcommand, sharedir, '--']
|
params = ['./src/ponysaytool.py', toolcommand, sharedir, '--']
|
||||||
for sharefile in os.listdir(sharedir):
|
for sharefile in os.listdir(sharedir):
|
||||||
if sharefile.endswith('.pony') and (sharefile != '.pony'):
|
if sharefile.endswith('.pony') and (sharefile != '.pony'):
|
||||||
if not Setup.validateFreedom(sharedir + '/' + sharefile):
|
if not Setup.validateFreedom(sharedir + '/' + sharefile):
|
||||||
print('Skipping metadata correction for %s/%s, did not pass validation process made by setup settings' % (sharedir, sharefile))
|
print('Skipping metadata correction for %s/%s, did not pass validation process made by setup settings' % (sharedir, sharefile))
|
||||||
else:
|
else:
|
||||||
params.append(sharefile)
|
params.append(sharefile)
|
||||||
print('%s, %s, %s (with files)' % ('./src/ponysay-tool.py', toolcommand, sharedir))
|
print('%s, %s, %s (with files)' % ('./src/ponysaytool.py', toolcommand, sharedir))
|
||||||
Popen(params, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
Popen(params, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
|
@ -56,8 +56,7 @@ if __name__ == '__main__':
|
||||||
istool = istool[:istool.find(os.extsep)]
|
istool = istool[:istool.find(os.extsep)]
|
||||||
istool = istool.endswith('-tool')
|
istool = istool.endswith('-tool')
|
||||||
if istool:
|
if istool:
|
||||||
from ponysaytool import *
|
from ponysaytool import * ## will start ponysay-tool
|
||||||
startponysaytool()
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
isthink = sys.argv[0]
|
isthink = sys.argv[0]
|
||||||
|
|
|
@ -1184,75 +1184,67 @@ class TextArea(): # TODO support small screens
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Start the program
|
The user's home directory
|
||||||
'''
|
'''
|
||||||
def startponysaytool():
|
HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~')
|
||||||
'''
|
|
||||||
The user's home directory
|
|
||||||
'''
|
|
||||||
HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~')
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Whether stdin is piped
|
Whether stdin is piped
|
||||||
'''
|
'''
|
||||||
pipelinein = not sys.stdin.isatty()
|
pipelinein = not sys.stdin.isatty()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Whether stdout is piped
|
Whether stdout is piped
|
||||||
'''
|
'''
|
||||||
pipelineout = not sys.stdout.isatty()
|
pipelineout = not sys.stdout.isatty()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Whether stderr is piped
|
Whether stderr is piped
|
||||||
'''
|
'''
|
||||||
pipelineerr = not sys.stderr.isatty()
|
pipelineerr = not sys.stderr.isatty()
|
||||||
|
|
||||||
|
|
||||||
usage_program = '\033[34;1mponysay-tool\033[21;39m'
|
usage_program = '\033[34;1mponysay-tool\033[21;39m'
|
||||||
|
|
||||||
usage = '\n'.join(['%s %s' % (usage_program, '(--help | --version | --kms)'),
|
usage = '\n'.join(['%s %s' % (usage_program, '(--help | --version | --kms)'),
|
||||||
'%s %s' % (usage_program, '(--edit | --edit-rm) \033[33mPONY-FILE\033[39m'),
|
'%s %s' % (usage_program, '(--edit | --edit-rm) \033[33mPONY-FILE\033[39m'),
|
||||||
'%s %s' % (usage_program, '--edit-stash \033[33mPONY-FILE\033[39m > \033[33mSTASH-FILE\033[39m'),
|
'%s %s' % (usage_program, '--edit-stash \033[33mPONY-FILE\033[39m > \033[33mSTASH-FILE\033[39m'),
|
||||||
'%s %s' % (usage_program, '--edit-apply \033[33mPONY-FILE\033[39m < \033[33mSTASH-FILE\033[39m'),
|
'%s %s' % (usage_program, '--edit-apply \033[33mPONY-FILE\033[39m < \033[33mSTASH-FILE\033[39m'),
|
||||||
'%s %s' % (usage_program, '(--dimensions | --metadata) \033[33mPONY-DIR\033[39m'),
|
'%s %s' % (usage_program, '(--dimensions | --metadata) \033[33mPONY-DIR\033[39m'),
|
||||||
'%s %s' % (usage_program, '--browse \033[33mPONY-DIR\033[39m [-r \033[33mRESTRICTION\033[39m]*'),
|
'%s %s' % (usage_program, '--browse \033[33mPONY-DIR\033[39m [-r \033[33mRESTRICTION\033[39m]*'),
|
||||||
])
|
])
|
||||||
|
|
||||||
usage = usage.replace('\033[', '\0')
|
usage = usage.replace('\033[', '\0')
|
||||||
for sym in ('[', ']', '(', ')', '|', '...', '*'):
|
for sym in ('[', ']', '(', ')', '|', '...', '*'):
|
||||||
usage = usage.replace(sym, '\033[2m' + sym + '\033[22m')
|
usage = usage.replace(sym, '\033[2m' + sym + '\033[22m')
|
||||||
usage = usage.replace('\0', '\033[')
|
usage = usage.replace('\0', '\033[')
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Argument parsing
|
Argument parsing
|
||||||
'''
|
'''
|
||||||
opts = ArgParser(program = 'ponysay-tool',
|
opts = ArgParser(program = 'ponysay-tool',
|
||||||
description = 'Tool chest for ponysay',
|
description = 'Tool chest for ponysay',
|
||||||
usage = usage,
|
usage = usage,
|
||||||
longdescription = None)
|
longdescription = None)
|
||||||
|
|
||||||
opts.add_argumentless(['--no-term-init']) # for debugging
|
opts.add_argumentless(['--no-term-init']) # for debugging
|
||||||
|
|
||||||
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
|
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
|
||||||
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
|
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
|
||||||
opts.add_argumentless(['--kms'], help = 'Generate all kmsponies for the current TTY palette')
|
opts.add_argumentless(['--kms'], help = 'Generate all kmsponies for the current TTY palette')
|
||||||
opts.add_argumented( ['--dimensions'], arg = 'PONY-DIR', help = 'Generate pony dimension file for a directory')
|
opts.add_argumented( ['--dimensions'], arg = 'PONY-DIR', help = 'Generate pony dimension file for a directory')
|
||||||
opts.add_argumented( ['--metadata'], arg = 'PONY-DIR', help = 'Generate pony metadata collection file for a directory')
|
opts.add_argumented( ['--metadata'], arg = 'PONY-DIR', help = 'Generate pony metadata collection file for a directory')
|
||||||
opts.add_argumented( ['-b', '--browse'], arg = 'PONY-DIR', help = 'Browse ponies in a directory')
|
opts.add_argumented( ['-b', '--browse'], arg = 'PONY-DIR', help = 'Browse ponies in a directory')
|
||||||
opts.add_argumented( ['-r', '--restrict'], arg = 'RESTRICTION', help = 'Metadata based restriction for --browse')
|
opts.add_argumented( ['-r', '--restrict'], arg = 'RESTRICTION', help = 'Metadata based restriction for --browse')
|
||||||
opts.add_argumented( ['--edit'], arg = 'PONY-FILE', help = 'Edit a pony file\'s metadata')
|
opts.add_argumented( ['--edit'], arg = 'PONY-FILE', help = 'Edit a pony file\'s metadata')
|
||||||
opts.add_argumented( ['--edit-rm'], arg = 'PONY-FILE', help = 'Remove metadata from a pony file')
|
opts.add_argumented( ['--edit-rm'], arg = 'PONY-FILE', help = 'Remove metadata from a pony file')
|
||||||
opts.add_argumented( ['--edit-apply'], arg = 'PONY-FILE', help = 'Apply metadata from stdin to a pony file')
|
opts.add_argumented( ['--edit-apply'], arg = 'PONY-FILE', help = 'Apply metadata from stdin to a pony file')
|
||||||
opts.add_argumented( ['--edit-stash'], arg = 'PONY-FILE', help = 'Print applyable metadata from a pony file')
|
opts.add_argumented( ['--edit-stash'], arg = 'PONY-FILE', help = 'Print applyable metadata from a pony file')
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Whether at least one unrecognised option was used
|
Whether at least one unrecognised option was used
|
||||||
'''
|
'''
|
||||||
unrecognised = not opts.parse()
|
unrecognised = not opts.parse()
|
||||||
|
|
||||||
PonysayTool(args = opts)
|
PonysayTool(args = opts)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
startponysaytool()
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue