From e5379adb32ed1420bb0fbeae5e3f1f6c1245236d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Sun, 28 Oct 2012 16:25:11 +0100 Subject: [PATCH] .ponysayrc support --- ponysay.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ponysay.py b/ponysay.py index b0389762..004aac73 100755 --- a/ponysay.py +++ b/ponysay.py @@ -830,7 +830,7 @@ class Ponysay(): balloon = self.__getballoon(balloonfile) if args.opts['-o'] is None else None ## Get hyphen style - hyphen = environ['PONYSAY_BOTTOM'] if 'PONYSAY_BOTTOM' in os.environ else None + hyphen = os.environ['PONYSAY_WRAP_HYPHEN'] if 'PONYSAY_WRAP_HYPHEN' in os.environ else None if (hyphen is None) or (len(hyphen) == 0): hyphen = '-' hyphencolour = '' @@ -2281,6 +2281,16 @@ if __name__ == '__main__': ''' HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~') + ## Change system enviroments with ~/.ponysayrc + if os.path.exists(HOME + '/.ponysayrc'): + with open(HOME + '/.ponysayrc', 'rb') as ponysayrc: + code = ponysayrc.read().decode('utf8', 'replace') + '\n' + env = os.environ + code = compile(code, HOME + '/.ponysayrc', 'exec') + exec(code) + + HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~') # in case ~/.ponysayrc changes it + ''' Whether the program is execute in Linux VT (TTY)