mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-26 06:07:59 +01:00
home dirs before sys dirs for priority + moving a method
This commit is contained in:
parent
0925635f44
commit
10268235a9
1 changed files with 20 additions and 18 deletions
38
ponysay.py
38
ponysay.py
|
@ -37,8 +37,8 @@ HOME = os.environ['HOME']
|
||||||
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
|
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
|
||||||
'''
|
'''
|
||||||
ponydirs = []
|
ponydirs = []
|
||||||
if os.environ['TERM'] == 'linux': _ponydirs = [INSTALLDIR + '/share/ponysay/ttyponies/', HOME + '/.local/share/ponysay/ttyponies/']
|
if os.environ['TERM'] == 'linux': _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
|
||||||
else: _ponydirs = [INSTALLDIR + '/share/ponysay/ponies/', HOME + '/.local/share/ponysay/ponies/' ]
|
else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
|
||||||
for ponydir in _ponydirs:
|
for ponydir in _ponydirs:
|
||||||
if os.path.isdir(ponydir):
|
if os.path.isdir(ponydir):
|
||||||
ponydirs.append(ponydir)
|
ponydirs.append(ponydir)
|
||||||
|
@ -48,7 +48,7 @@ for ponydir in _ponydirs:
|
||||||
The directories where quotes files are stored
|
The directories where quotes files are stored
|
||||||
'''
|
'''
|
||||||
quotedirs = []
|
quotedirs = []
|
||||||
_quotedirs = [INSTALLDIR + '/share/ponysay/quotes/', HOME + '/.local/share/ponysay/quotes/']
|
_quotedirs = [HOME + '/.local/share/ponysay/quotes/', INSTALLDIR + '/share/ponysay/quotes/']
|
||||||
for quotedir in _quotedirs:
|
for quotedir in _quotedirs:
|
||||||
if os.path.isdir(quotedir):
|
if os.path.isdir(quotedir):
|
||||||
quotedirs.append(quotedir)
|
quotedirs.append(quotedir)
|
||||||
|
@ -80,6 +80,23 @@ class ponysay():
|
||||||
else: self.print_pony(args)
|
else: self.print_pony(args)
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
Returns one .pony-file with full path, names is filter for names, also accepts filepaths
|
||||||
|
'''
|
||||||
|
def __getponypath(self, names = None):
|
||||||
|
ponies = {}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return ponies[names[random.randrange(0, len(names))]]
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Returns a set with all ponies that have quotes and are displayable
|
Returns a set with all ponies that have quotes and are displayable
|
||||||
'''
|
'''
|
||||||
|
@ -107,21 +124,6 @@ class ponysay():
|
||||||
|
|
||||||
return ponies
|
return ponies
|
||||||
|
|
||||||
'''
|
|
||||||
Returns one .pony-file with full path, names is filter for names, also accepts filepaths
|
|
||||||
'''
|
|
||||||
def __getponypath(self, names = None):
|
|
||||||
ponies = {}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
return ponies[names[random.randrange(0, len(names))]]
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Returns a list with all (pony, quote file) pairs
|
Returns a list with all (pony, quote file) pairs
|
||||||
|
|
Loading…
Reference in a new issue