lists.onelist(): Instead of passing multiple, possibly empty lists, build the list of directories to search before calling the method.

This commit is contained in:
Michael Schwarz 2014-08-30 12:44:00 +02:00
parent 5125dd6400
commit 8861e0bb0e
2 changed files with 7 additions and 7 deletions

View file

@ -198,16 +198,15 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None):
_print_columnised(list(ponies)) _print_columnised(list(ponies))
def onelist(standarddirs, extradirs, ucsiser): def onelist(pony_dirs, ucsiser):
''' '''
Lists the available ponies on one column without anything bold or otherwise formated Lists the available ponies on one column without anything bold or otherwise formated
@param standard:itr<str> Include standard ponies @param pony_dirs:itr<str> List of directories to search for ponies
@param extra:itr<str> Include extra ponies
@param ucsiser:(list<str>)void Function used to UCS:ise names @param ucsiser:(list<str>)void Function used to UCS:ise names
''' '''
## Get all pony files ## Get all pony files
ponies = [name for dir_list in [standarddirs, extradirs] for dir in dir_list for name in _get_file_list(dir, '.pony')] ponies = [name for dir in pony_dirs for name in _get_file_list(dir, '.pony')]
## UCS:ise and sort ## UCS:ise and sort
ucsiser(ponies) ucsiser(ponies)

View file

@ -760,9 +760,10 @@ class Ponysay():
@param standard:bool Include standard ponies @param standard:bool Include standard ponies
@param extra:bool Include extra ponies @param extra:bool Include extra ponies
''' '''
lists.onelist(self.ponydirs if standard else [],
self.extraponydirs if extra else [], pony_dirs = (self.ponydirs if standard else []) + (self.extraponydirs if extra else [])
self.__ucsise)
lists.onelist(pony_dirs, self.__ucsise)
def quoters(self, standard = True, extra = False): def quoters(self, standard = True, extra = False):