aboutsummaryrefslogtreecommitdiff
path: root/ponysay.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-18 20:36:18 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-18 20:36:18 +0200
commitf367346ad83b447ff9dfdc348f98eff1e4b28e26 (patch)
tree335fc2c69c7569326bb61b5978ca7353c7a442ef /ponysay.py
parent496b980a388e92f47a774d868140c6c5dbb6d678 (diff)
parenta4385d7754fefd06be8bbc78a398f02d32e8c191 (diff)
downloadponysay-f367346ad83b447ff9dfdc348f98eff1e4b28e26.tar.gz
ponysay-f367346ad83b447ff9dfdc348f98eff1e4b28e26.tar.bz2
ponysay-f367346ad83b447ff9dfdc348f98eff1e4b28e26.zip
Merge branch 'python' of github.com:erkin/ponysay into python
Diffstat (limited to 'ponysay.py')
-rwxr-xr-xponysay.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/ponysay.py b/ponysay.py
index 495bf5b..9d05e10 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -47,6 +47,12 @@ linuxvt = os.environ['TERM'] == 'linux'
'''
+Whether the program is launched in subshell/beeing redirected
+'''
+redirected = not sys.stdout.isatty()
+
+
+'''
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
'''
ponydirs = []
@@ -81,7 +87,7 @@ parser.add_argument( '--onelist', action = 'store_true', dest = 'onelist',
parser.add_argument('-W', '--wrap', action = 'store', dest = 'wrap', help = 'specify the column when the message should be wrapped')
parser.add_argument('-f', '--pony', action = 'append', dest = 'pony', help = 'select a pony (either a file name or a pony name)')
parser.add_argument('-q', '--quote', nargs = '*', dest = 'quote', help = 'select a pony which will quote herself')
-parser.add_argument('message', nargs = '?', help = 'message to ponysay')
+parser.add_argument('message', nargs = '?', help = 'message to ponysay')
args = parser.parse_args()
# TODO implement if [ -t 0 ] && [ $# == 0 ]; then
@@ -99,6 +105,10 @@ class ponysay():
Starts the part of the program the arguments indicate
'''
def __init__(self, args):
+ if args.list and redirected:
+ args.list = False
+ args.onelist = True
+
if args.list: self.list()
elif args.linklist: self.linklist()
elif args.quoters: self.quoters()