diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-10-27 23:45:02 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-10-27 23:45:02 +0200 |
commit | e3872aed44887c47d21b7b1240a2ac10787b80fc (patch) | |
tree | 2c42a606b55af691595de74b58361f2cfc44c6a7 /ponysay.py | |
parent | 7dc21f996b47e0f43becba51141a928b0de53939 (diff) | |
parent | 7c50985a1313880564f98b705e3b4f7324b0d82e (diff) | |
download | ponysay-e3872aed44887c47d21b7b1240a2ac10787b80fc.tar.gz ponysay-e3872aed44887c47d21b7b1240a2ac10787b80fc.tar.bz2 ponysay-e3872aed44887c47d21b7b1240a2ac10787b80fc.zip |
Merge branch 'develop'
Diffstat (limited to 'ponysay.py')
-rwxr-xr-x | ponysay.py | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -319,13 +319,13 @@ class Ponysay(): ponies[pony] = ponydir + ponyfile ## Support for explicit pony file names - if not names == None: + if names is not None: for name in names: if os.path.exists(name): ponies[name] = name ## If there is not select ponies, choose all of them - if names == None: + if (names is None) or (len(names) == 0): names = list(ponies.keys()) ## Select a random pony of the choosen onles @@ -806,11 +806,19 @@ class Ponysay(): if linuxvt: print('\033[H\033[2J', end='') - ## Width Get truncation and wrapping + ## Get width truncation and wrapping env_width = os.environ['PONYSAY_FULL_WIDTH'] if 'PONYSAY_FULL_WIDTH' in os.environ else None if env_width is None: env_width = '' widthtruncation = self.__gettermsize()[1] if env_width not in ('yes', 'y', '1') else None - messagewrap = int(args.opts['-W'][0]) if args.opts['-W'] is not None else None + messagewrap = 40 + if (args.opts['-W'] is not None) and (len(args.opts['-W'][0]) > 0): + messagewrap = args.opts['-W'][0] + if messagewrap[0] in 'nmsNMS': # m is left to n on QWERTY and s is left to n on Dvorak + messagewrap = None + elif messagewrap[0] in 'iouIOU': # o is left to i on QWERTY and u is right to i on Dvorak + messagewrap = self.__gettermsize()[1] + else: + messagewrap = int(args.opts['-W'][0]) ## Get balloon object balloonfile = self.__getballoonpath(args.opts['-b']) @@ -833,8 +841,8 @@ class Ponysay(): ## Run cowsay replacement - backend = Backend(message = msg, ponyfile = pony, wrapcolumn = messagewrap if messagewrap is not None else 40, - width = widthtruncation, balloon = balloon, hyphen = hyphen, linkcolour = linkcolour, ballooncolour = ballooncolour) + backend = Backend(message = msg, ponyfile = pony, wrapcolumn = messagewrap, width = widthtruncation, + balloon = balloon, hyphen = hyphen, linkcolour = linkcolour, ballooncolour = ballooncolour) backend.parse() output = backend.output if output.endswith('\n'): |