naturally...

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-01-02 07:22:38 +01:00
parent ab0177bad7
commit 221eac26f9
2 changed files with 15 additions and 17 deletions

View file

@ -189,6 +189,8 @@ class PonysayTool():
if key in args:
return args[key] if (args[key] is not None) and isinstance(args[key], list) else [args[key]]
return None
def __contains__(self, key):
return key in args;
stdout = sys.stdout
class StringInputStream:
@ -419,6 +421,8 @@ class PonysayTool():
self.value = value
def __getitem__(self, key):
return [self.value] if key == self.key else None
def __contains__(self, key):
return key == self.key;
class StringInputStream:
def __init__(self):
@ -485,6 +489,8 @@ class PonysayTool():
if key == ('-W' if self.balloon else '-b'):
return [('none' if self.balloon else None)]
return None
def __contains__(self, key):
return key in ('-f', '-W', '-b');
stdout = sys.stdout
class StringInputStream:
def __init__(self):
@ -647,6 +653,8 @@ class PonysayTool():
if key == '-f': return [ponyfile]
if key == '-W': return ['n']
return None
def __contains__(self, key):
return key in ('-f', '-W');
data = {}

View file

@ -303,23 +303,13 @@ class Ponysay():
self.extraponydirs = self.extravtponydirs if self.linuxvt and not self.usekms else self.extraxponydirs
## Variadic variants of -f, -q &c
if args.opts['--f'] is not None:
if args.opts['-f'] is not None: args.opts['-f'] += args.opts['--f']
else: args.opts['-f'] = args.opts['--f']
if args.opts['++f'] is not None:
if args.opts['+f'] is not None: args.opts['+f'] += args.opts['++f']
else: args.opts['+f'] = args.opts['++f']
if args.opts['--q'] is not None:
if args.opts['-q'] is not None: args.opts['-q'] += args.opts['--q']
else: args.opts['-q'] = args.opts['--q']
# FIXME the following is how it should be done, but it freezes the program
#for sign in ('-', '+'):
# for letter in ('f', 'F', 'q', 'Q'):
# ssl = sign + sign + letter
# sl = sign + letter
# if (ssl in args.opts) and (args.opts[ssl] is not None):
# if args.opts[sl] is not None: args.opts[sl] += args.opts[ssl]
# else: args.opts[sl] = args.opts[ssl]
for sign in ('-', '+'):
for letter in ('f', 'F', 'q', 'Q'):
ssl = sign + sign + letter
sl = sign + letter
if (ssl in args.opts) and (args.opts[ssl] is not None):
if args.opts[sl] is not None: args.opts[sl] += args.opts[ssl]
else: args.opts[sl] = args.opts[ssl]
## Run modes
if args.opts['-h'] is not None: args.help()