mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-25 13:57:59 +01:00
naturally...
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
ab0177bad7
commit
221eac26f9
2 changed files with 15 additions and 17 deletions
|
@ -189,6 +189,8 @@ class PonysayTool():
|
||||||
if key in args:
|
if key in args:
|
||||||
return args[key] if (args[key] is not None) and isinstance(args[key], list) else [args[key]]
|
return args[key] if (args[key] is not None) and isinstance(args[key], list) else [args[key]]
|
||||||
return None
|
return None
|
||||||
|
def __contains__(self, key):
|
||||||
|
return key in args;
|
||||||
|
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
class StringInputStream:
|
class StringInputStream:
|
||||||
|
@ -419,6 +421,8 @@ class PonysayTool():
|
||||||
self.value = value
|
self.value = value
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return [self.value] if key == self.key else None
|
return [self.value] if key == self.key else None
|
||||||
|
def __contains__(self, key):
|
||||||
|
return key == self.key;
|
||||||
|
|
||||||
class StringInputStream:
|
class StringInputStream:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -485,6 +489,8 @@ class PonysayTool():
|
||||||
if key == ('-W' if self.balloon else '-b'):
|
if key == ('-W' if self.balloon else '-b'):
|
||||||
return [('none' if self.balloon else None)]
|
return [('none' if self.balloon else None)]
|
||||||
return None
|
return None
|
||||||
|
def __contains__(self, key):
|
||||||
|
return key in ('-f', '-W', '-b');
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
class StringInputStream:
|
class StringInputStream:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -647,6 +653,8 @@ class PonysayTool():
|
||||||
if key == '-f': return [ponyfile]
|
if key == '-f': return [ponyfile]
|
||||||
if key == '-W': return ['n']
|
if key == '-W': return ['n']
|
||||||
return None
|
return None
|
||||||
|
def __contains__(self, key):
|
||||||
|
return key in ('-f', '-W');
|
||||||
|
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
|
|
24
ponysay.py
24
ponysay.py
|
@ -303,23 +303,13 @@ class Ponysay():
|
||||||
self.extraponydirs = self.extravtponydirs if self.linuxvt and not self.usekms else self.extraxponydirs
|
self.extraponydirs = self.extravtponydirs if self.linuxvt and not self.usekms else self.extraxponydirs
|
||||||
|
|
||||||
## Variadic variants of -f, -q &c
|
## Variadic variants of -f, -q &c
|
||||||
if args.opts['--f'] is not None:
|
for sign in ('-', '+'):
|
||||||
if args.opts['-f'] is not None: args.opts['-f'] += args.opts['--f']
|
for letter in ('f', 'F', 'q', 'Q'):
|
||||||
else: args.opts['-f'] = args.opts['--f']
|
ssl = sign + sign + letter
|
||||||
if args.opts['++f'] is not None:
|
sl = sign + letter
|
||||||
if args.opts['+f'] is not None: args.opts['+f'] += args.opts['++f']
|
if (ssl in args.opts) and (args.opts[ssl] is not None):
|
||||||
else: args.opts['+f'] = args.opts['++f']
|
if args.opts[sl] is not None: args.opts[sl] += args.opts[ssl]
|
||||||
if args.opts['--q'] is not None:
|
else: args.opts[sl] = args.opts[ssl]
|
||||||
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]
|
|
||||||
|
|
||||||
## Run modes
|
## Run modes
|
||||||
if args.opts['-h'] is not None: args.help()
|
if args.opts['-h'] is not None: args.help()
|
||||||
|
|
Loading…
Reference in a new issue