aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xponysay.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/ponysay.py b/ponysay.py
index c6c83f8..96acfbe 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -31,8 +31,8 @@ INSTALLDIR = '/usr'
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
'''
ponydirs = []
-if os.environ['TERM'] == 'linux': _ponydirs = [INSTALLDIR + '/share/ponysay/ttyponies/', os.environ['HOME'] + '/.local/share/ponysay/ttyponies/']
-else: _ponydirs = [INSTALLDIR + '/share/ponysay/ponies/', os.environ['HOME'] + '/.local/share/ponysay/ponies/' ]
+if os.environ['TERM'] == 'linux': _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
+else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
for ponydir in _ponydirs:
if os.path.isdir(ponydir):
ponydirs.append(ponydir)
@@ -42,7 +42,7 @@ for ponydir in _ponydirs:
The directories where quotes files are stored
'''
quotedirs = []
-_quotedirs = [INSTALLDIR + '/share/ponysay/quotes/', os.environ['HOME'] + '/.local/share/ponysay/quotes/']
+_quotedirs = [HOME + '/.local/share/ponysay/quotes/', INSTALLDIR + '/share/ponysay/quotes/']
for quotedir in _quotedirs:
if os.path.isdir(quotedir):
quotedirs.append(quotedir)
@@ -75,6 +75,27 @@ class ponysay():
'''
+ Returns one .pony-file with full path, names is filter for names, also accepts filepaths
+ '''
+ def __getponypath(self, names = None):
+ ponies = {}
+
+ if names != None:
+ for name in names:
+ if os.path.isfile(name):
+ return name
+
+ for ponydir in ponydirs:
+ for ponyfile in os.listdir(ponydir):
+ ponies[ponyfile[:-5]] = ponydir + ponyfile
+
+ if names == None:
+ names = list(ponies.keys())
+
+ return ponies[names[random.randrange(0, len(names))]]
+
+
+ '''
Returns a set with all ponies that have quotes and are displayable
'''
def __quoters(self):
@@ -101,25 +122,6 @@ class ponysay():
return ponies
- '''
- Returns one .pony-file with full path, names is filter for names, also accepts filepaths
- '''
- def __getponypath(self, names = None):
- ponies = {}
-
- if names != None:
- for name in names:
- if os.path.isfile(name):
- return name
-
- for ponydir in ponydirs:
- for ponyfile in os.listdir(ponydir):
- ponies[ponyfile[:-5]] = ponydir + ponyfile
-
- if names == None:
- names = list(ponies.keys())
-
- return ponies[names[random.randrange(0, len(names))]]
'''
Returns a list with all (pony, quote file) pairs