From eac35c124a30c2cc02ceb72129a4180239dcab57 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 19 Aug 2012 04:55:38 +0200 Subject: .png files in -f if util-say is installed --- manuals/ponysay.texinfo | 13 ++++++++++++- ponysay.pdf | Bin 326551 -> 328307 bytes ponysay.py | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index 10ee03a..fd65186 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -139,6 +139,9 @@ a relative path and does not include a `@code{/}', it must begin with multiple times to specify a set of ponies from which one will be selected randomly. If no pony is specified one will be selected randomly. +If you have @command{util-say} installed, you can use .png-files as the +arguments for this options. + @item -q [PONY...] @itemx --quote [PONY...] @cindex @command{-q} @@ -485,6 +488,14 @@ Python version 3 is the primary language of the program @cindex linux vt For improved TTY support for user with custom colour palette and KMS support. It can be downloaded at @url{https://github.com/maandree/util-say}. + +@cindex png images +@cindex images, png +@cindex portable network graphics +For ther purpose of simplying for pony contributors, @command{ponysay} +supports using .png-images (note that the file must not miss the +@code{.png} in the file) in addition of .pony-files or pony names. + @end table @@ -1265,7 +1276,7 @@ Patchers and other contributors of ponysay: @itemize @bullet @item Duane ``Marneus68'' Bekaert @item Kyah ``L-four'' Rindlisbacher -@item James `rossy2401'' Ross-Gowan +@item James ``rossy2401'' Ross-Gowan @item Louis ``kragniz'' Taylor @item Jannis ``sycoso'' @item ``spider-mario'' diff --git a/ponysay.pdf b/ponysay.pdf index ec86d80..712bdaf 100644 Binary files a/ponysay.pdf and b/ponysay.pdf differ diff --git a/ponysay.py b/ponysay.py index b5cc2b2..8d41cba 100755 --- a/ponysay.py +++ b/ponysay.py @@ -25,7 +25,7 @@ from subprocess import Popen, PIPE ''' The version of ponysay ''' -VERSION = '2.0-rc1' +VERSION = '2.0-rc2' ''' @@ -122,7 +122,7 @@ class ponysay(): ## ''' - Returns one .pony-file with full path, names is filter for names, also accepts filepaths + Returns one file with full path, names is filter for names, also accepts filepaths. ''' def __getponypath(self, names = None): ponies = {} @@ -130,7 +130,7 @@ class ponysay(): if not names == None: for name in names: if os.path.isfile(name): - return name + ponies[name] = name for ponydir in ponydirs: for ponyfile in os.listdir(ponydir): @@ -342,7 +342,7 @@ class ponysay(): Returns (the cowsay command, whether it is a custom program) ''' def __getcowsay(self): - isthink = 'think.py' in __file__ + isthink = (len(__file__) >= 8) and (__file__[-8:] == 'think.py') if isthink: cowthink = os.environ['PONYSAY_COWTHINK'] if 'PONYSAY_COWTHINK' in os.environ else None @@ -361,9 +361,17 @@ class ponysay(): else: msg = args.message + pony = self.__getponypath(args.pony) (cowsay, customcowsay) = self.__getcowsay() + if (len(pony) > 4) and (pony[-4:].lower() == '.png'): + pony = '\'' + pony.replace('\'', '\'\\\'\'') + '\'' + pngcmd = ('img2ponysay -p -- ' if linuxvt else 'img2ponysay -- ') + pony + pngpipe = os.pipe() + Popen(pngcmd, stdout=os.fdopen(pngpipe[1], 'w'), shell=True).wait() + pony = '/proc/' + str(os.getpid()) + '/fd/' + str(pngpipe[0]) + cmd = [cowsay, '-f', self.__kms(pony)] if args.wrap is not None: cmd += ['-W', args.wrap] -- cgit