aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay34
1 files changed, 32 insertions, 2 deletions
diff --git a/ponysay b/ponysay
index fedaab6..96ce9e6 100755
--- a/ponysay
+++ b/ponysay
@@ -16,6 +16,7 @@ License: WTFPL
'''
import os
+import shutil
import sys
import random
from subprocess import Popen, PIPE
@@ -24,7 +25,7 @@ from subprocess import Popen, PIPE
'''
The version of ponysay
'''
-VERSION = '2.2'
+VERSION = '2.3'
'''
@@ -533,6 +534,8 @@ class Ponysay():
if not linuxvt:
return pony
+ KMS_VERSION = '1'
+
env_kms = os.environ['PONYSAY_KMS_PALETTE'] if 'PONYSAY_KMS_PALETTE' in os.environ else None
if env_kms is None: env_kms = ''
@@ -554,6 +557,33 @@ class Ponysay():
if not os.path.isdir(cachedir):
os.makedirs(cachedir)
+ newversion = False
+ if not os.path.isfile(cachedir + '/.version'):
+ newversion = True
+ else:
+ cachev = None
+ try:
+ cachev = open(cachedir + '/.version', 'r')
+ if ''.join(cachev.readlines()) == KMS_VERSION:
+ newversion = True
+ finally:
+ if cachev is not None:
+ cachev.close()
+ if newversion:
+ for cached in os.listdir(cachedir):
+ cached = cachedir + '/' + cached
+ if os.path.isdir(cached) and not os.path.islink(cached):
+ shutil.rmtree(cached, False)
+ else:
+ os.remove(cached)
+ cachev = None
+ try:
+ cachev = open(cachedir + '/.version', 'w+')
+ cachev.write(KMS_VERSION)
+ finally:
+ if cachev is not None:
+ cachev.close()
+
kmsponies = cachedir + '/kmsponies/' + palettefile
kmspony = (kmsponies + pony).replace('//', '/')
@@ -1326,7 +1356,7 @@ class ColourStack():
elif (1 <= p) and (p <= 9): self.stack[0][3][p - 1] = True
elif (21 <= p) and (p <= 29): self.stack[0][3][p - 21] = False
elif p == 39: self.stack[0][1] = None
- elif p == 40: self.stack[0][2] = None
+ elif p == 49: self.stack[0][2] = None
elif (30 <= p) and (p <= 37): self.stack[0][1] = part
elif (90 <= p) and (p <= 97): self.stack[0][1] = part
elif (40 <= p) and (p <= 47): self.stack[0][2] = part