aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-18 15:10:49 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-18 15:10:49 +0200
commit73d477ce1b57d82150bff04d74e6eb2dc1391a3d (patch)
tree5189729786483b4c0a7f4d5cc853a7bd935b074d
parentfeeaa47ad8b519ba2b042225e3cebb43e9a1f0ab (diff)
downloadponysay-73d477ce1b57d82150bff04d74e6eb2dc1391a3d.tar.gz
ponysay-73d477ce1b57d82150bff04d74e6eb2dc1391a3d.tar.bz2
ponysay-73d477ce1b57d82150bff04d74e6eb2dc1391a3d.zip
m + a method for getting all quotes
-rwxr-xr-xponysay.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/ponysay.py b/ponysay.py
index 8de7541..46a3932 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -61,11 +61,11 @@ class ponysay():
quoteshash = set()
_quotes = [item[:item.index('.')] for item in os.listdir(INSTALLDIR + '/share/ponysay/quotes/')]
for quote in _quotes:
- if not quote[0] == '.':
+ if not quote == '':
if not quote in quoteshash:
quoteshash.add(quote)
quotes.append(quote)
-
+
ponies = set()
for ponydir in ponydirs:
for pony in os.listdir(ponydir):
@@ -78,6 +78,25 @@ class ponysay():
return ponies
+
+ '''
+ Returns a list with all (pony, quote file) pairs
+ '''
+ def __quotes(self):
+ quotes = os.listdir(INSTALLDIR + '/share/ponysay/quotes/')
+ rc = []
+
+ for ponydir in ponydirs:
+ for pony in os.listdir(ponydir):
+ if not pony[0] == '.':
+ p = pony[:-5] # remove .pony
+ for quote in quotes:
+ if ('+' + p + '+') in ('+' + quote + '+'):
+ rc.append((p, qoute))
+
+ return rc
+
+
'''
Lists the available ponies
'''
@@ -106,7 +125,8 @@ class ponysay():
x = 0
print("\n");
-
+
+
def print_pony(self, args):
if args.message == None:
msg = sys.stdin.read().strip()