Whoops. Fix an overlooked mistake regarding the filename.

This commit is contained in:
Erkin Batu Altunbaş 2013-05-21 16:36:35 +03:00
parent 0747fab2e1
commit ce1d99f3cb

363
setup.py
View file

@ -36,7 +36,7 @@ mansections = [('ponysay', '6'),
('fortune', '6')] ('fortune', '6')]
miscfiles = [('COPYING', '/usr/share/licenses/ponysay/COPYING'), miscfiles = [('COPYING', '/usr/share/licenses/ponysay/COPYING'),
('LICENSE', '/usr/share/licenses/ponysay/LICENSE'), ('LICENCE', '/usr/share/licenses/ponysay/LICENCE'),
('CREDITS', '/usr/share/licenses/ponysay/CREDITS')] ('CREDITS', '/usr/share/licenses/ponysay/CREDITS')]
ponysaysrc = [src + '.py' for src in ponysaysrc = [src + '.py' for src in
@ -56,205 +56,205 @@ class Setup():
usage_script = '\033[34;1msetup.py\033[21;39m' usage_script = '\033[34;1msetup.py\033[21;39m'
usage_help = '(version | help)' usage_help = '(version | help)'
usage_proc = '[\033[4mconfigurations\033[24m] ([build] | prebuilt | install | (uninstall|clean)[-old] | view)' usage_proc = '[\033[4mconfigurations\033[24m] ([build] | prebuilt | install | (uninstall|clean)[-old] | view)'
usage = '%s %s\n%s %s' % (usage_script, usage_help, usage_script, usage_proc) usage = '%s %s\n%s %s' % (usage_script, usage_help, usage_script, usage_proc)
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[')
opts = ArgParser(program = 'setup.py', opts = ArgParser(program = 'setup.py',
description = 'installer for ponysay', description = 'installer for ponysay',
usage = usage) usage = usage)
opts.add_argumentless(alternatives = ['--help']) opts.add_argumentless(alternatives = ['--help'])
opts.add_argumentless(alternatives = ['--version']) opts.add_argumentless(alternatives = ['--version'])
opts.add_argumented (alternatives = ['---DESTDIR'], arg="DESTDIR") opts.add_argumented (alternatives = ['---DESTDIR'], arg="DESTDIR")
opts.add_argumented (alternatives = ['---PREFIX'], arg="PREFIX") opts.add_argumented (alternatives = ['---PREFIX'], arg="PREFIX")
opts.add_argumentless(help = 'Install everything that is not explicity excluded', opts.add_argumentless(help = 'Install everything that is not explicity excluded',
alternatives = ['--everything', '--with-everything']) alternatives = ['--everything', '--with-everything'])
opts.add_argumentless(help = 'Install only the essentials\nNote that this can vary depending on version', opts.add_argumentless(help = 'Install only the essentials\nNote that this can vary depending on version',
alternatives = ['--minimal']) alternatives = ['--minimal'])
opts.add_argumentless(help = 'Install nothing (except legal documents) that is not explicity included', opts.add_argumentless(help = 'Install nothing (except legal documents) that is not explicity included',
alternatives = ['--nothing', '--with-nothing']) alternatives = ['--nothing', '--with-nothing'])
for command in commands: for command in commands:
opts.add_argumentless(help = 'Do not install the %s command' % (command), opts.add_argumentless(help = 'Do not install the %s command' % (command),
alternatives = ['--without-' + command, '--without-' + command + '-command']) alternatives = ['--without-' + command, '--without-' + command + '-command'])
opts.add_argumented (help = 'Install the %s command, and set file name\nDefualt = /usr/bin/%s' % (command, command), opts.add_argumented (help = 'Install the %s command, and set file name\nDefualt = /usr/bin/%s' % (command, command),
alternatives = ['--with-' + command, '--with-' + command + '-command'], arg='EXEC') alternatives = ['--with-' + command, '--with-' + command + '-command'], arg='EXEC')
opts.add_argumentless(help = 'Do not install a user shared cache', opts.add_argumentless(help = 'Do not install a user shared cache',
alternatives = ['--without-shared-cache']) alternatives = ['--without-shared-cache'])
opts.add_argumented (help = 'Install a user shared cache at CACHEDIR\nDefault = /var/cache/ponysay', opts.add_argumented (help = 'Install a user shared cache at CACHEDIR\nDefault = /var/cache/ponysay',
alternatives = [ '--with-shared-cache'], arg='CACHEDIR') alternatives = [ '--with-shared-cache'], arg='CACHEDIR')
for shell in shells: for shell in shells:
opts.add_argumentless(help = 'Do not install completion for ' + shell[2], opts.add_argumentless(help = 'Do not install completion for ' + shell[2],
alternatives = ['--without-' + shell[0], '--without-' + shell[0] + '-completion']) alternatives = ['--without-' + shell[0], '--without-' + shell[0] + '-completion'])
opts.add_argumented (help = 'Set file name for the completion for ponysay in' + shell[2], opts.add_argumented (help = 'Set file name for the completion for ponysay in' + shell[2],
alternatives = ['--with-' + shell[0], '--with-' + shell[0] + '-completion'], arg='PONYSAY_%s_FILE' % (shell[0].upper())) alternatives = ['--with-' + shell[0], '--with-' + shell[0] + '-completion'], arg='PONYSAY_%s_FILE' % (shell[0].upper()))
opts.add_argumentless(help = 'Only install explicitly included shell completions', opts.add_argumentless(help = 'Only install explicitly included shell completions',
alternatives = ['--without-shell', '--without-shell-completion']) alternatives = ['--without-shell', '--without-shell-completion'])
opts.add_argumented (help = 'Set share/ directory used for shell completions\nDefault = $SHAREDIR', opts.add_argumented (help = 'Set share/ directory used for shell completions\nDefault = $SHAREDIR',
alternatives = ['--with-shell', '--with-shell-completion'], arg='SHAREDIR') alternatives = ['--with-shell', '--with-shell-completion'], arg='SHAREDIR')
opts.add_argumentless(help = 'Do not install PDF manual\nDefault', opts.add_argumentless(help = 'Do not install PDF manual\nDefault',
alternatives = ['--without-pdf', '--without-pdf-manual']) alternatives = ['--without-pdf', '--without-pdf-manual'])
opts.add_argumented (help = 'Set directory for PDF manual\nDefault = $PREFIX/doc', opts.add_argumented (help = 'Set directory for PDF manual\nDefault = $PREFIX/doc',
alternatives = ['--with-pdf', '--with-pdf-manual'], arg='DOCDIR') alternatives = ['--with-pdf', '--with-pdf-manual'], arg='DOCDIR')
opts.add_argumentless(help = 'Do not compress PDF manual\nDefault', opts.add_argumentless(help = 'Do not compress PDF manual\nDefault',
alternatives = ['--without-pdf-compression', '--without-pdf-manual-compression']) alternatives = ['--without-pdf-compression', '--without-pdf-manual-compression'])
opts.add_argumented (help = 'Select compression for PDF manual\nDefault = gz, xz is also recognised', opts.add_argumented (help = 'Select compression for PDF manual\nDefault = gz, xz is also recognised',
alternatives = ['--with-pdf-compression', '--with-pdf-manual-compression'], arg='COMPRESSION') alternatives = ['--with-pdf-compression', '--with-pdf-manual-compression'], arg='COMPRESSION')
opts.add_argumentless(help = 'Do not install info manual', opts.add_argumentless(help = 'Do not install info manual',
alternatives = ['--without-info', '--without-info-manual']) alternatives = ['--without-info', '--without-info-manual'])
opts.add_argumented (help = 'Set directory for info manual\nDefault = $SHARE/info', opts.add_argumented (help = 'Set directory for info manual\nDefault = $SHARE/info',
alternatives = ['--with-info', '--with-info-manual'], arg='INFODIR') alternatives = ['--with-info', '--with-info-manual'], arg='INFODIR')
opts.add_argumentless(help = 'Do not use install-info when installing info manual', opts.add_argumentless(help = 'Do not use install-info when installing info manual',
alternatives = ['--without-info-install', '--without-info-manual-install']) alternatives = ['--without-info-install', '--without-info-manual-install'])
opts.add_argumented (help = 'Use install-info when installing info manual, and set description\nDefault', opts.add_argumented (help = 'Use install-info when installing info manual, and set description\nDefault',
alternatives = ['--with-info-install', '--with-info-manual-install'], arg='DESCRIPTION') alternatives = ['--with-info-install', '--with-info-manual-install'], arg='DESCRIPTION')
opts.add_argumentless(help = 'Do not compress info manual', opts.add_argumentless(help = 'Do not compress info manual',
alternatives = ['--without-info-compression', '--without-info-manual-compression']) alternatives = ['--without-info-compression', '--without-info-manual-compression'])
opts.add_argumented (help = 'Select compression for info manual\nDefault = gz, xz is also recognised', opts.add_argumented (help = 'Select compression for info manual\nDefault = gz, xz is also recognised',
alternatives = ['--with-info-compression', '--with-info-manual-compression'], arg='COMPRESSION') alternatives = ['--with-info-compression', '--with-info-manual-compression'], arg='COMPRESSION')
for man in manpages: for man in manpages:
opts.add_argumentless(help = 'Do not install %s manpage manual' % (man[1]), opts.add_argumentless(help = 'Do not install %s manpage manual' % (man[1]),
alternatives = ['--without-man-%s' % (man[0]), '--without-manpage-%s' % (man[0]), '--without-man-manual-%s' % (man[0]), alternatives = ['--without-man-%s' % (man[0]), '--without-manpage-%s' % (man[0]), '--without-man-manual-%s' % (man[0]),
'--without-%s-man' % (man[0]), '--without-%s-manpage' % (man[0]), '--without-%s-man-manual' % (man[0])]) '--without-%s-man' % (man[0]), '--without-%s-manpage' % (man[0]), '--without-%s-man-manual' % (man[0])])
opts.add_argumented (help = 'Set directory for %s manpage\nDefault = $SHARE/man' % (man[1]), opts.add_argumented (help = 'Set directory for %s manpage\nDefault = $SHARE/man' % (man[1]),
alternatives = ['--with-man-%s' % (man[0]), '--with-manpage-%s' % (man[0]), '--with-man-manual-%s' % (man[0]), alternatives = ['--with-man-%s' % (man[0]), '--with-manpage-%s' % (man[0]), '--with-man-manual-%s' % (man[0]),
'--with-%s-man' % (man[0]), '--with-%s-manpage' % (man[0]), '--with-%s-man-manual' % (man[0])], arg='MANDIR') '--with-%s-man' % (man[0]), '--with-%s-manpage' % (man[0]), '--with-%s-man-manual' % (man[0])], arg='MANDIR')
opts.add_argumentless(help = 'Do not install any manpages', opts.add_argumentless(help = 'Do not install any manpages',
alternatives = ['--without-man', '--without-manpage', '--without-man-manual']) alternatives = ['--without-man', '--without-manpage', '--without-man-manual'])
opts.add_argumented (help = 'Set directory for all man pages\nDefault = $SHARE/man', opts.add_argumented (help = 'Set directory for all man pages\nDefault = $SHARE/man',
alternatives = ['--with-man', '--with-manpage', '--with-man-manual'], arg='MANDIR') alternatives = ['--with-man', '--with-manpage', '--with-man-manual'], arg='MANDIR')
for man in manpages: for man in manpages:
opts.add_argumentless(help = 'Do not compress %s manpage' % (man[1]), opts.add_argumentless(help = 'Do not compress %s manpage' % (man[1]),
alternatives = ['--without-man-%s-compression' % (man[0]), '--without-manpage-%s-compression' % (man[0]), '--without-man-manual-%s-compression' % (man[0]), alternatives = ['--without-man-%s-compression' % (man[0]), '--without-manpage-%s-compression' % (man[0]), '--without-man-manual-%s-compression' % (man[0]),
'--without-%s-man-compression' % (man[0]), '--without-%s-manpage-compression' % (man[0]), '--without-%s-man-manual-compression' % (man[0])]) '--without-%s-man-compression' % (man[0]), '--without-%s-manpage-compression' % (man[0]), '--without-%s-man-manual-compression' % (man[0])])
opts.add_argumented (help = 'Select compression for %s manpage\nDefault = gz, xz is also recognised' % (man[1]), opts.add_argumented (help = 'Select compression for %s manpage\nDefault = gz, xz is also recognised' % (man[1]),
alternatives = ['--with-man-%s-compression' % (man[0]), '--with-manpage-%s-compression' % (man[0]), '--with-man-manual-%s-compression' % (man[0]), alternatives = ['--with-man-%s-compression' % (man[0]), '--with-manpage-%s-compression' % (man[0]), '--with-man-manual-%s-compression' % (man[0]),
'--with-%s-man-compression' % (man[0]), '--with-%s-manpage-compression' % (man[0]), '--with-%s-man-manual-compression' % (man[0])], '--with-%s-man-compression' % (man[0]), '--with-%s-manpage-compression' % (man[0]), '--with-%s-man-manual-compression' % (man[0])],
arg='COMPRESSION') arg='COMPRESSION')
opts.add_argumentless(help = 'Do not compress any installed manpage', opts.add_argumentless(help = 'Do not compress any installed manpage',
alternatives = ['--without-man-compression', '--without-manpage-compression', '--without-man-manual-compression']) alternatives = ['--without-man-compression', '--without-manpage-compression', '--without-man-manual-compression'])
opts.add_argumented (help = 'Select compression for installed manpages\nDefault = gz, xz is also recognised', opts.add_argumented (help = 'Select compression for installed manpages\nDefault = gz, xz is also recognised',
alternatives = ['--with-man-compression', '--with-manpage-compression', '--with-man-manual-compression'], arg='COMPRESSION') alternatives = ['--with-man-compression', '--with-manpage-compression', '--with-man-manual-compression'], arg='COMPRESSION')
for man in mansections: for man in mansections:
opts.add_argumented (help = 'Change the section for the %s manpage\nDefault = %s' % man, opts.add_argumented (help = 'Change the section for the %s manpage\nDefault = %s' % man,
alternatives = ['--man-section-%s' % (man[0]), '--%s-manpage-section' % (man[0]), alternatives = ['--man-section-%s' % (man[0]), '--%s-manpage-section' % (man[0]),
'--man-section-%s' % (man[0]), '--%s-manpage-section' % (man[0])], arg='SECTION') '--man-section-%s' % (man[0]), '--%s-manpage-section' % (man[0])], arg='SECTION')
for dir in sharedirs: for dir in sharedirs:
opts.add_argumentless(help = 'Do not install ' + dir[1], opts.add_argumentless(help = 'Do not install ' + dir[1],
alternatives = ['--without-' + dir[0]]) alternatives = ['--without-' + dir[0]])
opts.add_argumentless(help = 'Install %s\nDefault' % dir[1], opts.add_argumentless(help = 'Install %s\nDefault' % dir[1],
alternatives = [ '--with-' + dir[0]]) alternatives = [ '--with-' + dir[0]])
opts.add_argumentless(help = 'Do not install UCS pony name map', opts.add_argumentless(help = 'Do not install UCS pony name map',
alternatives = ['--without-ucs', '--without-ucs-names']) alternatives = ['--without-ucs', '--without-ucs-names'])
opts.add_argumentless(help = 'Install UCS pony name map\nDefault', opts.add_argumentless(help = 'Install UCS pony name map\nDefault',
alternatives = ['--with-ucs', '--with-ucs-names']) alternatives = ['--with-ucs', '--with-ucs-names'])
opts.add_argumentless(help = 'Let the installer set the env name for python in ponysay\nDefault', opts.add_argumentless(help = 'Let the installer set the env name for python in ponysay\nDefault',
alternatives = ['--without-custom-env-python']) alternatives = ['--without-custom-env-python'])
opts.add_argumented (help = 'Set the env name for python in ponysay', opts.add_argumented (help = 'Set the env name for python in ponysay',
alternatives = ['--with-custom-env-python'], arg='PYTHON') alternatives = ['--with-custom-env-python'], arg='PYTHON')
opts.add_argumented (help = 'Set a prefix to all implicit directories\nDefault = /usr', opts.add_argumented (help = 'Set a prefix to all implicit directories\nDefault = /usr',
alternatives = ['--prefix'], arg='PREFIX') alternatives = ['--prefix'], arg='PREFIX')
opts.add_argumentless(help = 'Change all implicit configurations to fit local user a installation for the current user', opts.add_argumentless(help = 'Change all implicit configurations to fit local user a installation for the current user',
alternatives = ['--private']) alternatives = ['--private'])
opts.add_argumentless(help = 'Change all implicit directories to fit installation to /opt', opts.add_argumentless(help = 'Change all implicit directories to fit installation to /opt',
alternatives = ['--opt']) alternatives = ['--opt'])
opts.add_argumented (help = 'Set the system\'s directory for command executables\nDefault = $PREFIX/bin', opts.add_argumented (help = 'Set the system\'s directory for command executables\nDefault = $PREFIX/bin',
alternatives = ['--bin-dir'], arg='BINDIR') alternatives = ['--bin-dir'], arg='BINDIR')
opts.add_argumented (help = 'Set the system\'s directory for non-executable libraries\nDefault = $PREFIX/lib/ponysay\nNot used.', opts.add_argumented (help = 'Set the system\'s directory for non-executable libraries\nDefault = $PREFIX/lib/ponysay\nNot used.',
alternatives = ['--lib-dir'], arg='LIBDIR') alternatives = ['--lib-dir'], arg='LIBDIR')
opts.add_argumented (help = 'Set the system\'s directory for non-command executables\nDefault = $PREFIX/libexec/ponysay\nNot used.', opts.add_argumented (help = 'Set the system\'s directory for non-command executables\nDefault = $PREFIX/libexec/ponysay\nNot used.',
alternatives = ['--libexec-dir'], arg='LIBEXECDIR') alternatives = ['--libexec-dir'], arg='LIBEXECDIR')
opts.add_argumented (help = 'Set the system\'s directory for resource files\nDefault = $PREFIX/share', opts.add_argumented (help = 'Set the system\'s directory for resource files\nDefault = $PREFIX/share',
alternatives = ['--share-dir'], arg='SHAREDIR') alternatives = ['--share-dir'], arg='SHAREDIR')
opts.add_argumented (help = 'Set the system\'s local specific configuration directory\nDefault = /etc', opts.add_argumented (help = 'Set the system\'s local specific configuration directory\nDefault = /etc',
alternatives = ['--sysconf-dir'], arg='SYSCONFDIR') alternatives = ['--sysconf-dir'], arg='SYSCONFDIR')
opts.add_argumented (help = 'Set the system\'s directory for cache directories\nDefault = /var/cache', opts.add_argumented (help = 'Set the system\'s directory for cache directories\nDefault = /var/cache',
alternatives = ['--cache-dir'], arg='CACHEDIR') alternatives = ['--cache-dir'], arg='CACHEDIR')
opts.add_argumented (help = 'Set off environment for installation\nEmpty by default', opts.add_argumented (help = 'Set off environment for installation\nEmpty by default',
alternatives = ['--dest-dir'], arg='DESTDIR') alternatives = ['--dest-dir'], arg='DESTDIR')
opts.add_argumented (help = 'Set how to link identical files\nDefault = symbolic, copy and hard are also recognised', opts.add_argumented (help = 'Set how to link identical files\nDefault = symbolic, copy and hard are also recognised',
alternatives = ['--linking'], arg='TYPE') alternatives = ['--linking'], arg='TYPE')
opts.add_argumented (help = 'Install all ponies or only the completely free ponies\nThis option is manditory, use strict, full, true or yes ' + opts.add_argumented (help = 'Install all ponies or only the completely free ponies\nThis option is manditory, use strict, full, true or yes ' +
'for only free ponies,\nand partial, sloppy, false or no for all ponies', 'for only free ponies,\nand partial, sloppy, false or no for all ponies',
alternatives = ['--freedom'], arg='FREEDOM') alternatives = ['--freedom'], arg='FREEDOM')
opts.parse() opts.parse()
self.linking = SYMBOLIC self.linking = SYMBOLIC
if opts.opts['--linking'] is not None: if opts.opts['--linking'] is not None:
self.linking = opts.opts['--linking'][0] self.linking = opts.opts['--linking'][0]
self.free = None self.free = None
if opts.opts['--freedom'] is not None: if opts.opts['--freedom'] is not None:
if opts.opts['--freedom'][0].lower() in ('strict', 'full', 'true', 'yes'): if opts.opts['--freedom'][0].lower() in ('strict', 'full', 'true', 'yes'):
@ -271,19 +271,19 @@ class Setup():
print('') print('')
print('') print('')
exit(255) exit(255)
if (opts.opts['---DESTDIR'] is not None) and (opts.opts['--dest-dir'] is None): if (opts.opts['---DESTDIR'] is not None) and (opts.opts['--dest-dir'] is None):
destdir = opts.opts['---DESTDIR'][0] destdir = opts.opts['---DESTDIR'][0]
if len(destdir) > 0: if len(destdir) > 0:
opts.opts['--dest-dir'] = [destdir] opts.opts['--dest-dir'] = [destdir]
if (opts.opts['---PREFIX'] is not None) and (opts.opts['--prefix'] is None): if (opts.opts['---PREFIX'] is not None) and (opts.opts['--prefix'] is None):
prefix = opts.opts['---PREFIX'][0] prefix = opts.opts['---PREFIX'][0]
if len(prefix) > 0: if len(prefix) > 0:
opts.opts['--prefix'] = [prefix] opts.opts['--prefix'] = [prefix]
if (len(opts.files) > 1) or (opts.opts['--help'] is not None) or ((len(opts.files) == 1) and (opts.files[0] == 'help')): if (len(opts.files) > 1) or (opts.opts['--help'] is not None) or ((len(opts.files) == 1) and (opts.files[0] == 'help')):
opts.help() opts.help()
elif (opts.opts['--version'] is not None) or ((len(opts.files) == 1) and (opts.files[0] == 'version')): elif (opts.opts['--version'] is not None) or ((len(opts.files) == 1) and (opts.files[0] == 'version')):
@ -297,30 +297,30 @@ class Setup():
else: else:
conf = self.configure(opts.opts) conf = self.configure(opts.opts)
self.viewconf(conf) self.viewconf(conf)
if method == 'build': if method == 'build':
self.build(conf) self.build(conf)
elif method == 'prebuilt': elif method == 'prebuilt':
self.applyDestDir(conf) self.applyDestDir(conf)
self.install(conf) self.install(conf)
elif method == 'install': elif method == 'install':
self.build(conf) self.build(conf)
self.applyDestDir(conf) self.applyDestDir(conf)
self.install(conf) self.install(conf)
self.clean() self.clean()
elif method == 'uninstall': elif method == 'uninstall':
self.uninstall(conf) self.uninstall(conf)
elif method == 'uninstall-old': elif method == 'uninstall-old':
self.uninstallOld(conf) self.uninstallOld(conf)
elif not method == 'view': elif not method == 'view':
opts.help() opts.help()
''' '''
Display configurations Display configurations
''' '''
@ -328,7 +328,7 @@ class Setup():
RED = '\033[31m%s\033[39m' RED = '\033[31m%s\033[39m'
GREEN = '%s\033[32m%s\033[39m' GREEN = '%s\033[32m%s\033[39m'
YELLOW = '\033[33m%s\033[39m' YELLOW = '\033[33m%s\033[39m'
for command in commands: for command in commands:
if conf[command] is not None: print(GREEN % ('Installing command ' + command + ' as ', conf[command])) if conf[command] is not None: print(GREEN % ('Installing command ' + command + ' as ', conf[command]))
else: print(RED % ('Skipping installion of command ' + command)) else: print(RED % ('Skipping installion of command ' + command))
@ -368,20 +368,20 @@ class Setup():
print('Prefered linking style: ' + self.linking) print('Prefered linking style: ' + self.linking)
if self.free: print(GREEN % ('', 'Installing only fully free parts of the package')) if self.free: print(GREEN % ('', 'Installing only fully free parts of the package'))
else: print(RED % ('Installing \033[1mnot\033[21m only fully free parts of the package')) else: print(RED % ('Installing \033[1mnot\033[21m only fully free parts of the package'))
print() print()
''' '''
Compile ponysay Compile ponysay
''' '''
def build(self, conf): def build(self, conf):
print('\033[1;34m::\033[39mCompiling...\033[21m') print('\033[1;34m::\033[39mCompiling...\033[21m')
def compressCommand(ext): def compressCommand(ext):
if ext == 'gz': return 'gzip -9 -f' if ext == 'gz': return 'gzip -9 -f'
if ext == 'xz': return 'xz -9e -f' if ext == 'xz': return 'xz -9e -f'
def compress(source, destination, ext): def compress(source, destination, ext):
print('%s < %s > %s' % (compressCommand(ext), source, destination)) print('%s < %s > %s' % (compressCommand(ext), source, destination))
(fileout, filein) = (None, None) (fileout, filein) = (None, None)
@ -392,9 +392,9 @@ class Setup():
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()
(fileout, filein) = (None, None) (fileout, filein) = (None, None)
env = conf['custom-env-python'] env = conf['custom-env-python']
if env is None: if env is None:
try: try:
@ -417,7 +417,7 @@ class Setup():
fileout = open('src/%s.install' % src, 'wb+') fileout = open('src/%s.install' % src, 'wb+')
filein = open('src/%s' % src, 'rb') filein = open('src/%s' % src, 'rb')
data = filein.read().decode('utf-8', 'replace') data = filein.read().decode('utf-8', 'replace')
if '#!/usr/bin/env python3' in data: if '#!/usr/bin/env python3' in data:
data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env) data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env)
else: else:
@ -425,7 +425,7 @@ class Setup():
data = data.replace('/usr/share/ponysay/', conf['share-dir'] + ('' if conf['share-dir'].endswith('/') else '/')) data = data.replace('/usr/share/ponysay/', conf['share-dir'] + ('' if conf['share-dir'].endswith('/') else '/'))
data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/')) data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/'))
data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION))
fileout.write(data.encode('utf-8')) fileout.write(data.encode('utf-8'))
finally: finally:
if fileout is not None: fileout.close() if fileout is not None: fileout.close()
@ -447,7 +447,7 @@ class Setup():
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()
for man in manpages: for man in manpages:
key = 'man-' + man[0] key = 'man-' + man[0]
section = conf['man-section-ponysay'] section = conf['man-section-ponysay']
@ -461,11 +461,11 @@ class Setup():
fileout = open(dest, 'wb+') fileout = open(dest, 'wb+')
filein = open(src, 'rb') filein = open(src, 'rb')
data = filein.read().decode('utf-8', 'replace') 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.encode('utf-8')) fileout.write(data.encode('utf-8'))
finally: finally:
if fileout is not None: fileout.close() if fileout is not None: fileout.close()
@ -475,19 +475,19 @@ class Setup():
if ext is not None: if ext is not None:
dest = 'manuals/manpage' + lang + '.0.' + ext dest = 'manuals/manpage' + lang + '.0.' + ext
compress(src, dest, ext) compress(src, dest, ext)
if conf['info'] is not None: if conf['info'] is not None:
print('makeinfo manuals/ponysay.texinfo') print('makeinfo manuals/ponysay.texinfo')
os.system('makeinfo manuals/ponysay.texinfo') os.system('makeinfo manuals/ponysay.texinfo')
ext = conf['info-compression'] ext = conf['info-compression']
if ext is not None: if ext is not None:
compress('ponysay.info', 'ponysay.info.' + ext, ext) compress('ponysay.info', 'ponysay.info.' + ext, ext)
if conf['pdf-compression'] is not None: if conf['pdf-compression'] is not None:
ext = conf['pdf-compression'] ext = conf['pdf-compression']
if ext is not None: if ext is not None:
compress('ponysay.pdf', 'ponysay.pdf.' + ext, ext) compress('ponysay.pdf', 'ponysay.pdf.' + ext, ext)
for command in commands: for command in commands:
source = 'completion/ponysay' source = 'completion/ponysay'
sourceed = 'completion/ponysay.%s' % (command) sourceed = 'completion/ponysay.%s' % (command)
@ -495,7 +495,7 @@ class Setup():
fileout = open(sourceed, 'wb+') fileout = open(sourceed, 'wb+')
filein = open(source, 'rb') filein = open(source, 'rb')
data = filein.read().decode('utf-8', 'replace') data = filein.read().decode('utf-8', 'replace')
if data.startswith('(ponysay\n'): if data.startswith('(ponysay\n'):
data = ('(%s ' % command) + data[len('(ponysay\n'):] data = ('(%s ' % command) + data[len('(ponysay\n'):]
elif data.startswith('(ponysay '): elif data.startswith('(ponysay '):
@ -507,12 +507,12 @@ class Setup():
data = data[:edpos] + ('\n(%s ' % command) + data[edpas + len('\n(ponysay '):] data = data[:edpos] + ('\n(%s ' % command) + data[edpas + len('\n(ponysay '):]
else: else:
raise Exception('File %s does not look like expected' % source) raise Exception('File %s does not look like expected' % source)
fileout.write(data.encode('utf-8')) 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()
for shell in [item[0] for item in shells]: for shell in [item[0] for item in shells]:
if conf[shell] is not None: if conf[shell] is not None:
for command in commands: for command in commands:
@ -527,18 +527,18 @@ class Setup():
fileout = open(dest, 'wb+') fileout = open(dest, 'wb+')
filein = open(generated, 'rb') filein = open(generated, 'rb')
data = filein.read().decode('utf-8', 'replace') 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')
data = data.replace('ponysay', command) data = data.replace('ponysay', command)
data = data.replace('/usr/share/ponysay/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) data = data.replace('/usr/share/ponysay/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/'))
data = data.replace('\0', '/ponysay') data = data.replace('\0', '/ponysay')
fileout.write(data.encode('utf-8')) 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()
if conf['quotes'] is not None: if conf['quotes'] is not None:
self.removeLists([], ['quotes']) self.removeLists([], ['quotes'])
os.mkdir('quotes') os.mkdir('quotes')
@ -557,7 +557,7 @@ class Setup():
finally: finally:
if ponymap is not None: if ponymap is not None:
ponymap.close() ponymap.close()
for (sharedir, hasponies) in [(sharedir[0], sharedir[3]) for sharedir in sharedirs]: for (sharedir, hasponies) in [(sharedir[0], sharedir[3]) for sharedir in sharedirs]:
if hasponies and os.path.isdir(sharedir): if hasponies and os.path.isdir(sharedir):
for toolcommand in ('--dimensions', '--metadata'): for toolcommand in ('--dimensions', '--metadata'):
@ -574,16 +574,16 @@ class Setup():
params.append(sharefile) params.append(sharefile)
print('%s, %s, %s (with files)' % ('./src/ponysaytool.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()
''' '''
Install compiled ponysay Install compiled ponysay
''' '''
def install(self, conf): def install(self, conf):
print('\033[1;34m::\033[39mInstalling...\033[21m') print('\033[1;34m::\033[39mInstalling...\033[21m')
dests = [] dests = []
for command in commands: for command in commands:
if conf[command] is not None: if conf[command] is not None:
@ -663,16 +663,16 @@ class Setup():
for file in miscfiles: for file in miscfiles:
self.cp(False, file[0], [conf[file[0]]], Setup.validateFreedom if self.free else None) self.cp(False, file[0], [conf[file[0]]], Setup.validateFreedom if self.free else None)
print() print()
''' '''
Uninstall ponysay Uninstall ponysay
''' '''
def uninstall(self, conf): def uninstall(self, conf):
print('\033[1;34m::\033[39mUninstalling...\033[21m') print('\033[1;34m::\033[39mUninstalling...\033[21m')
(files, dirs, infos) = ([], [], []) (files, dirs, infos) = ([], [], [])
for command in commands: for command in commands:
if conf[command] is not None: if conf[command] is not None:
files.append(conf[command]) files.append(conf[command])
@ -712,23 +712,23 @@ class Setup():
files.append(ponyshare + file[0]) files.append(ponyshare + file[0])
for file in miscfiles: for file in miscfiles:
files.append(conf[file[0]]) files.append(conf[file[0]])
for info in infos: for info in infos:
cmdarr = ['install-info', '--delete', '--dir-file=' + conf['info'] + '/dir', info] cmdarr = ['install-info', '--delete', '--dir-file=' + conf['info'] + '/dir', info]
cmd = ' '.join(['\'%s\'' % (elem.replace('\'', '\'\\\'\'')) for elem in cmdarr]) cmd = ' '.join(['\'%s\'' % (elem.replace('\'', '\'\\\'\'')) for elem in cmdarr])
print('Uninstalling info manual ' + info + ' with install-info') print('Uninstalling info manual ' + info + ' with install-info')
os.system(cmd) os.system(cmd)
self.removeLists(files, dirs) self.removeLists(files, dirs)
print() print()
''' '''
Uninstall file ponysay no longer uses Uninstall file ponysay no longer uses
''' '''
def uninstallOld(self, conf): def uninstallOld(self, conf):
print('\033[1;34m::\033[39mUninstalling old files...\033[21m') print('\033[1;34m::\033[39mUninstalling old files...\033[21m')
instdir = conf['~prefix~'] + '/usr' instdir = conf['~prefix~'] + '/usr'
files = [instdir + f for f in ['bin/ponysaylist.pl', 'bin/ponysaytruncater', 'bin/ponysay.py', 'bin/ponythink.py']] files = [instdir + f for f in ['bin/ponysaylist.pl', 'bin/ponysaytruncater', 'bin/ponysay.py', 'bin/ponythink.py']]
dirs = [instdir + d for d in ['lib/ponysay', 'share/ponies', 'share/ttyponies']] dirs = [instdir + d for d in ['lib/ponysay', 'share/ponies', 'share/ttyponies']]
@ -739,17 +739,17 @@ class Setup():
#$(instdir)/lib/ponysay/pq4ps.pl #$(instdir)/lib/ponysay/pq4ps.pl
#$(instdir)/lib/ponysay/pq4ps-list #$(instdir)/lib/ponysay/pq4ps-list
#$(instdir)/lib/ponysay/pq4ps-list.pl #$(instdir)/lib/ponysay/pq4ps-list.pl
self.removeLists(files, dirs) self.removeLists(files, dirs)
print() print()
''' '''
Remove compiled files Remove compiled files
''' '''
def clean(self): def clean(self):
print('\033[1;34m::\033[39mCleaning...\033[21m') print('\033[1;34m::\033[39mCleaning...\033[21m')
files = ['ponysay.info', 'ponysay.info.gz', 'ponysay.info.xz', 'ponysay.pdf.gz', 'ponysay.pdf.xz', 'ponysay.install'] files = ['ponysay.info', 'ponysay.info.gz', 'ponysay.info.xz', 'ponysay.pdf.gz', 'ponysay.pdf.xz', 'ponysay.install']
files += ['src/%s.install' % file for file in ponysaysrc] files += ['src/%s.install' % file for file in ponysaysrc]
dirs = ['quotes'] dirs = ['quotes']
@ -766,17 +766,17 @@ class Setup():
for sharedir in [sharedir[0] for sharedir in sharedirs]: for sharedir in [sharedir[0] for sharedir in sharedirs]:
for dimfile in ('widths', 'heights', 'onlyheights'): for dimfile in ('widths', 'heights', 'onlyheights'):
files.append(sharedir + '/' + dimfile) files.append(sharedir + '/' + dimfile)
self.removeLists(files, dirs) self.removeLists(files, dirs)
print() print()
''' '''
Remove compiled files ponysay is no longer compiling Remove compiled files ponysay is no longer compiling
''' '''
def cleanOld(self): def cleanOld(self):
print('\033[1;34m::\033[39mCleaning old files...\033[21m') print('\033[1;34m::\033[39mCleaning old files...\033[21m')
files = ['truncater', 'ponysaytruncater', 'ponysay.py.install', 'ponysay.install~', 'ponysay.zip'] files = ['truncater', 'ponysaytruncater', 'ponysay.py.install', 'ponysay.install~', 'ponysay.zip']
dirs = [] dirs = []
for shell in [item[0] for item in shells]: for shell in [item[0] for item in shells]:
@ -785,11 +785,11 @@ class Setup():
for shell in [item[0] for item in shells]: for shell in [item[0] for item in shells]:
for command in commands: for command in commands:
files.append('completion/%s-completion.%s.%s' % (shell, 'sh' if shell == 'bash' else shell, command)) files.append('completion/%s-completion.%s.%s' % (shell, 'sh' if shell == 'bash' else shell, command))
self.removeLists(files, dirs) self.removeLists(files, dirs)
print() print()
''' '''
Removes listed files and directories Removes listed files and directories
''' '''
@ -818,8 +818,8 @@ class Setup():
os.rmdir(dir) os.rmdir(dir)
else: else:
break; break;
''' '''
Check whether a file is fully free Check whether a file is fully free
''' '''
@ -839,8 +839,8 @@ class Setup():
return line[1].lower() == 'yes' return line[1].lower() == 'yes'
return False return False
return True return True
''' '''
Copys a files or directory to multiple destinations Copys a files or directory to multiple destinations
''' '''
@ -918,8 +918,8 @@ class Setup():
if os.path.exists(dest): if os.path.exists(dest):
os.unlink(dest) os.unlink(dest)
self.symlink(target, dest) self.symlink(target, dest)
''' '''
Create a symlink with a relative path Create a symlink with a relative path
''' '''
@ -931,25 +931,25 @@ class Setup():
else: else:
targets = target.split('/') targets = target.split('/')
dests = dest.split('/') dests = dest.split('/')
while (len(targets) > 1) and (len(dests) > 1) and (targets[0] == dests[0]): while (len(targets) > 1) and (len(dests) > 1) and (targets[0] == dests[0]):
targets = targets[1:] targets = targets[1:]
dests = dests[1:] dests = dests[1:]
if (len(dests) == 1): if (len(dests) == 1):
targets = ['.'] + targets targets = ['.'] + targets
else: else:
targets = (['..'] * (len(dests) - 1)) + targets targets = (['..'] * (len(dests) - 1)) + targets
os.symlink('/'.join(targets), dest) os.symlink('/'.join(targets), dest)
''' '''
Parses configurations Parses configurations
''' '''
def configure(self, opts): def configure(self, opts):
(defaults, conf) = ({}, {}) (defaults, conf) = ({}, {})
for command in commands: for command in commands:
conf[command] = '/usr/bin/' + command conf[command] = '/usr/bin/' + command
conf['shared-cache'] = '/var/cache/ponysay' conf['shared-cache'] = '/var/cache/ponysay'
@ -975,12 +975,12 @@ class Setup():
conf['lib-dir'] = '/usr/lib/ponysay' conf['lib-dir'] = '/usr/lib/ponysay'
conf['libexec-dir'] = '/usr/libexec/ponysay' conf['libexec-dir'] = '/usr/libexec/ponysay'
conf['share-dir'] = '/usr/share' conf['share-dir'] = '/usr/share'
if opts['--private'] is not None: if opts['--private'] is not None:
if opts['--prefix'] is None: if opts['--prefix'] is None:
opts['--prefix'] = [os.environ['HOME'] + '/.local'] opts['--prefix'] = [os.environ['HOME'] + '/.local']
prefix = '/usr' prefix = '/usr'
if opts['--prefix'] is not None: if opts['--prefix'] is not None:
prefix = opts['--prefix'][0] prefix = opts['--prefix'][0]
@ -989,14 +989,14 @@ class Setup():
if conf[key].startswith('/usr'): if conf[key].startswith('/usr'):
conf[key] = prefix + conf[key][4:] conf[key] = prefix + conf[key][4:]
conf['~prefix~'] = prefix conf['~prefix~'] = prefix
if opts['--opt'] is not None: if opts['--opt'] is not None:
if opts['--bin-dir'] is None: opts['--bin-dir'] = ['/opt/ponysay'] if opts['--bin-dir'] is None: opts['--bin-dir'] = ['/opt/ponysay']
if opts['--lib-dir'] is None: opts['--lib-dir'] = ['/opt/ponysay'] if opts['--lib-dir'] is None: opts['--lib-dir'] = ['/opt/ponysay']
if opts['--libexec-dir'] is None: opts['--libexec-dir'] = ['/opt/ponysay'] if opts['--libexec-dir'] is None: opts['--libexec-dir'] = ['/opt/ponysay']
if opts['--share-dir'] is None: opts['--share-dir'] = ['/opt/ponysay'] if opts['--share-dir'] is None: opts['--share-dir'] = ['/opt/ponysay']
if opts['--with-shared-cache'] is None: opts['--with-shared-cache'] = ['/var/opt/ponysay/cache'] if opts['--with-shared-cache'] is None: opts['--with-shared-cache'] = ['/var/opt/ponysay/cache']
for dir in ['bin', 'lib', 'libexec', 'share']: for dir in ['bin', 'lib', 'libexec', 'share']:
key = dir + '-dir' key = dir + '-dir'
if opts['--' + key] is not None: if opts['--' + key] is not None:
@ -1011,35 +1011,35 @@ class Setup():
if conf[key] not in (None, False, True): if conf[key] not in (None, False, True):
if conf[key].startswith('/var/cache'): if conf[key].startswith('/var/cache'):
conf[key] = dir + conf[key][10:] conf[key] = dir + conf[key][10:]
if opts['--sysconf-dir'] is not None: if opts['--sysconf-dir'] is not None:
conf['sysconf-dir'] = opts['--sysconf-dir'][0] conf['sysconf-dir'] = opts['--sysconf-dir'][0]
for key in conf: for key in conf:
defaults[key] = conf[key] defaults[key] = conf[key]
if opts['--nothing'] is not None: if opts['--nothing'] is not None:
opts['--minimal'] = opts['--nothing'] opts['--minimal'] = opts['--nothing']
for key in ['custom-env-python']: for key in ['custom-env-python']:
conf[key] = None conf[key] = None
if opts['--everything'] is None: if opts['--everything'] is None:
for key in ['pdf', 'pdf-compression']: for key in ['pdf', 'pdf-compression']:
conf[key] = None conf[key] = None
nomanen = opts['--minimal'] is not None nomanen = opts['--minimal'] is not None
for manpage in manpages: for manpage in manpages:
if (manpage is not manpages[0]) or nomanen: if (manpage is not manpages[0]) or nomanen:
for key in ['man-' + manpage[0]]: for key in ['man-' + manpage[0]]:
conf[key] = None conf[key] = None
if (opts['--private'] is not None) or (opts['--minimal'] is not None): if (opts['--private'] is not None) or (opts['--minimal'] is not None):
for key in ['info-install', 'shared-cache']: for key in ['info-install', 'shared-cache']:
conf[key] = None conf[key] = None
if opts['--minimal'] is not None: if opts['--minimal'] is not None:
for key in ['info'] + [item[0] for item in shells]: for key in ['info'] + [item[0] for item in shells]:
conf[key] = None conf[key] = None
@ -1048,13 +1048,13 @@ class Setup():
conf[sharedir[0]] = None conf[sharedir[0]] = None
for sharefile in sharefiles: for sharefile in sharefiles:
conf[sharefile[0]] = None conf[sharefile[0]] = None
if opts['--nothing'] is not None: if opts['--nothing'] is not None:
for command in commands: for command in commands:
conf[command] = None conf[command] = None
conf[sharedirs[0][0]] = None conf[sharedirs[0][0]] = None
for coll in [['shell', '/usr/share', [item[0] for item in shells]], for coll in [['shell', '/usr/share', [item[0] for item in shells]],
['man', '/usr/share/man', ['man-' + item[0] for item in manpages]], ['man', '/usr/share/man', ['man-' + item[0] for item in manpages]],
['man-compression', 'gz', ['man-' + item[0] + '-compression' for item in manpages]] ['man-compression', 'gz', ['man-' + item[0] + '-compression' for item in manpages]]
@ -1065,8 +1065,8 @@ class Setup():
if opts['--with-' + coll[0]] is not None: if opts['--with-' + coll[0]] is not None:
for item in coll[2]: for item in coll[2]:
defaults[item] = conf[item] = defaults[item].replace(coll[1], coll[1] if opts['--with-' + coll[0]][0] is None else opts['--with-' + coll[0]][0]); defaults[item] = conf[item] = defaults[item].replace(coll[1], coll[1] if opts['--with-' + coll[0]][0] is None else opts['--with-' + coll[0]][0]);
for key in conf: for key in conf:
if '--with-' + key not in opts: if '--with-' + key not in opts:
continue continue
@ -1077,27 +1077,27 @@ class Setup():
conf[key] = defaults[key] if opts['--with-' + key][0] is None else opts['--with-' + key][0] conf[key] = defaults[key] if opts['--with-' + key][0] is None else opts['--with-' + key][0]
if opts['--without-' + key] is not None: if opts['--without-' + key] is not None:
conf[key] = False if defaults[key] in (False, True) else None conf[key] = False if defaults[key] in (False, True) else None
for mansection in mansections: for mansection in mansections:
if opts['--man-section-' + mansection[0]] is not None: if opts['--man-section-' + mansection[0]] is not None:
conf['man-section-' + mansection[0]] = opts['--man-section-' + mansection[0]][0] conf['man-section-' + mansection[0]] = opts['--man-section-' + mansection[0]][0]
else: else:
conf['man-section-' + mansection[0]] = mansection[1] conf['man-section-' + mansection[0]] = mansection[1]
self.destDir = None if opts['--dest-dir'] is None else opts['--dest-dir'][0] self.destDir = None if opts['--dest-dir'] is None else opts['--dest-dir'][0]
return conf return conf
def applyDestDir(self, conf): def applyDestDir(self, conf):
if self.destDir is not None: if self.destDir is not None:
for key in conf: for key in conf:
if conf[key] not in (None, False, True): if conf[key] not in (None, False, True):
if conf[key].startswith('/'): if conf[key].startswith('/'):
conf[key] = self.destDir + conf[key] conf[key] = self.destDir + conf[key]
def unapplyDestDir(self, conf): def unapplyDestDir(self, conf):
if self.destDir is not None: if self.destDir is not None:
for key in conf: for key in conf:
@ -1124,7 +1124,7 @@ class ArgParser():
self.__longdescription = longdescription self.__longdescription = longdescription
self.__arguments = [] self.__arguments = []
(self.opts, self.optmap) = ({}, {}) (self.opts, self.optmap) = ({}, {})
''' '''
Add option that takes no arguments Add option that takes no arguments
''' '''
@ -1133,7 +1133,7 @@ class ArgParser():
self.__arguments.append((ARGUMENTLESS, alternatives, None, help)) self.__arguments.append((ARGUMENTLESS, alternatives, None, help))
(stdalt, self.opts[stdalt]) = (alternatives[0], None) (stdalt, self.opts[stdalt]) = (alternatives[0], None)
for alt in alternatives: self.optmap[alt] = (stdalt, ARGUMENTLESS) for alt in alternatives: self.optmap[alt] = (stdalt, ARGUMENTLESS)
''' '''
Add option that takes one argument Add option that takes one argument
''' '''
@ -1141,7 +1141,7 @@ class ArgParser():
self.__arguments.append((ARGUMENTED, alternatives, arg, help)) self.__arguments.append((ARGUMENTED, alternatives, arg, help))
(stdalt, self.opts[stdalt]) = (alternatives[0], None) (stdalt, self.opts[stdalt]) = (alternatives[0], None)
for alt in alternatives: self.optmap[alt] = (stdalt, ARGUMENTED) for alt in alternatives: self.optmap[alt] = (stdalt, ARGUMENTED)
''' '''
Parse arguments Parse arguments
''' '''
@ -1149,7 +1149,7 @@ class ArgParser():
self.argcount = len(argv) - 1 self.argcount = len(argv) - 1
self.files = [] self.files = []
(argqueue, optqueue, get) = ([], [], False) (argqueue, optqueue, get) = ([], [], False)
for arg in argv[1:]: for arg in argv[1:]:
if get: if get:
get = False get = False
@ -1178,7 +1178,7 @@ class ArgParser():
exit(-1) exit(-1)
else: else:
self.files.append(arg) self.files.append(arg)
(i, n) = (0, len(optqueue)) (i, n) = (0, len(optqueue))
if len(argqueue) < n: if len(argqueue) < n:
argqueue.append(None) argqueue.append(None)
@ -1190,7 +1190,7 @@ class ArgParser():
else: else:
sys.stderr.write('%s: fatal: duplicate option %s\n' % (self.__program, arg)) sys.stderr.write('%s: fatal: duplicate option %s\n' % (self.__program, arg))
exit(-1) exit(-1)
''' '''
Prints a colourful help message Prints a colourful help message
''' '''
@ -1225,4 +1225,3 @@ class ArgParser():
if __name__ == '__main__': if __name__ == '__main__':
Setup() Setup()