mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-07 21:46:42 +01:00
m + a method for getting all quotes
This commit is contained in:
parent
feeaa47ad8
commit
73d477ce1b
1 changed files with 23 additions and 3 deletions
22
ponysay.py
22
ponysay.py
|
@ -61,7 +61,7 @@ class ponysay():
|
||||||
quoteshash = set()
|
quoteshash = set()
|
||||||
_quotes = [item[:item.index('.')] for item in os.listdir(INSTALLDIR + '/share/ponysay/quotes/')]
|
_quotes = [item[:item.index('.')] for item in os.listdir(INSTALLDIR + '/share/ponysay/quotes/')]
|
||||||
for quote in _quotes:
|
for quote in _quotes:
|
||||||
if not quote[0] == '.':
|
if not quote == '':
|
||||||
if not quote in quoteshash:
|
if not quote in quoteshash:
|
||||||
quoteshash.add(quote)
|
quoteshash.add(quote)
|
||||||
quotes.append(quote)
|
quotes.append(quote)
|
||||||
|
@ -78,6 +78,25 @@ class ponysay():
|
||||||
|
|
||||||
return ponies
|
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
|
Lists the available ponies
|
||||||
'''
|
'''
|
||||||
|
@ -107,6 +126,7 @@ class ponysay():
|
||||||
|
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
||||||
|
|
||||||
def print_pony(self, args):
|
def print_pony(self, args):
|
||||||
if args.message == None:
|
if args.message == None:
|
||||||
msg = sys.stdin.read().strip()
|
msg = sys.stdin.read().strip()
|
||||||
|
|
Loading…
Reference in a new issue