From 3bb5a68d7f081225fa6a77e2537fe62650c872fc Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sat, 18 Aug 2012 18:47:02 +0200 Subject: Drop newline at end of file of ponyquotes --- ponysay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ponysay.py b/ponysay.py index 632445d..5c45ed9 100755 --- a/ponysay.py +++ b/ponysay.py @@ -353,7 +353,7 @@ class ponysay(): qfile = None try: qfile = open(pair[1], 'r') - args.message = '\n'.join(qfile.readlines()) + args.message = '\n'.join(qfile.readlines()).strip() finally: if qfile is not None: qfile.close() -- cgit From 2301f094ad3227e49d3def485448660301f60dac Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sat, 18 Aug 2012 18:54:04 +0200 Subject: Fallback quote for ponies without quotes --- ponysay.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ponysay.py b/ponysay.py index 5c45ed9..33a4b01 100755 --- a/ponysay.py +++ b/ponysay.py @@ -349,15 +349,19 @@ class ponysay(): alts.append(pair) pairs = alts - pair = pairs[random.randrange(0, len(pairs))] - qfile = None - try: - qfile = open(pair[1], 'r') - args.message = '\n'.join(qfile.readlines()).strip() - finally: - if qfile is not None: - qfile.close() - args.pony = [pair[0]] + if not len(pairs) == 0: + pair = pairs[random.randrange(0, len(pairs))] + qfile = None + try: + qfile = open(pair[1], 'r') + args.message = '\n'.join(qfile.readlines()).strip() + finally: + if qfile is not None: + qfile.close() + args.pony = [pair[0]] + else: + args.pony = args.quote + args.message = 'I got nuthin\' good to say :(' self.print_pony(args) -- cgit From 378da89d3be748c4727839cb240255421fcd5789 Mon Sep 17 00:00:00 2001 From: Elis Date: Sat, 18 Aug 2012 19:57:08 +0300 Subject: Removed some stuff implemented in ponysay.py --- ponysay.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ponysay.sh b/ponysay.sh index e390f09..9338c58 100755 --- a/ponysay.sh +++ b/ponysay.sh @@ -7,10 +7,6 @@ INSTALLDIR="$(dirname $( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))" # Subscripts truncatercmd="$INSTALLDIR/lib/ponysay/truncater" -pony="*" # Selected pony -wrap="" # Message wrap column -ponies=() # Selected ponies - scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` # Screen width scrh=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 1` # Screen height @@ -98,17 +94,6 @@ say() { fi } - - -# If no stdin and no arguments then print usage and exit -if [ -t 0 ] && [ $# == 0 ]; then - usage - exit -fi - - - - # Check for cowsay hash $cmd &>/dev/null; if [ $? -ne 0 ]; then cat >&2 <