list.py: Moved static functions to module level.

This commit is contained in:
Michael Schwarz 2014-08-24 18:17:09 +02:00
parent 5e87dadc02
commit 69461d20fc
2 changed files with 217 additions and 224 deletions

View file

@ -28,18 +28,16 @@ whether or not you may commercially redistribute an image make use
that line FREE: yes, is included inside the image between two $$$ that line FREE: yes, is included inside the image between two $$$
lines and the FREE is and upper case and directly followed by lines and the FREE is and upper case and directly followed by
the colon. the colon.
File listing functions.
''' '''
from ucs import * from ucs import *
def _columnise(ponies):
class List():
'''
File listing functions
'''
@staticmethod
def __columnise(ponies):
''' '''
Columnise a list and prints it Columnise a list and prints it
@ -92,7 +90,6 @@ class List():
print() print()
@staticmethod
def simplelist(ponydirs, quoters = [], ucsiser = None): def simplelist(ponydirs, quoters = [], ucsiser = None):
''' '''
Lists the available ponies Lists the available ponies
@ -119,10 +116,9 @@ class List():
if len(ponies) == 0: if len(ponies) == 0:
continue continue
print('\033[1mponies located in ' + ponydir + '\033[21m') print('\033[1mponies located in ' + ponydir + '\033[21m')
List.__columnise([(pony, '\033[1m' + pony + '\033[21m' if pony in quoters else pony) for pony in ponies]) _columnise([(pony, '\033[1m' + pony + '\033[21m' if pony in quoters else pony) for pony in ponies])
@staticmethod
def linklist(ponydirs = None, quoters = [], ucsiser = None): def linklist(ponydirs = None, quoters = [], ucsiser = None):
''' '''
Lists the available ponies with alternatives inside brackets Lists the available ponies with alternatives inside brackets
@ -197,10 +193,9 @@ class List():
ponies[(item.replace('\033[1m', '').replace('\033[21m', ''), item)] = w ponies[(item.replace('\033[1m', '').replace('\033[21m', ''), item)] = w
## Print the ponies, columnised ## Print the ponies, columnised
List.__columnise(list(ponies)) _columnise(list(ponies))
@staticmethod
def onelist(standarddirs, extradirs = None, ucsiser = None): def onelist(standarddirs, extradirs = None, ucsiser = None):
''' '''
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
@ -237,7 +232,6 @@ class List():
print(pony) print(pony)
@staticmethod
def balloonlist(balloondirs, isthink): def balloonlist(balloondirs, isthink):
''' '''
Prints a list of all balloons Prints a list of all balloons
@ -265,5 +259,4 @@ class List():
balloonset.add(balloon) balloonset.add(balloon)
## Print all balloos, columnised ## Print all balloos, columnised
List.__columnise([(balloon, balloon) for balloon in list(balloonset)]) _columnise([(balloon, balloon) for balloon in balloonset])

View file

@ -35,7 +35,7 @@ from balloon import *
from spellocorrecter import * from spellocorrecter import *
from ucs import * from ucs import *
from kms import * from kms import *
from list import * import list as _list
from metadata import * from metadata import *
@ -739,7 +739,7 @@ class Ponysay():
@param ponydirs:itr<str>? The pony directories to use @param ponydirs:itr<str>? The pony directories to use
''' '''
List.simplelist(self.ponydirs if ponydirs is None else ponydirs, _list.simplelist(self.ponydirs if ponydirs is None else ponydirs,
self.__quoters(), lambda x : self.__ucsise(x)) self.__quoters(), lambda x : self.__ucsise(x))
@ -749,7 +749,7 @@ class Ponysay():
@param ponydirs:itr<str> The pony directories to use @param ponydirs:itr<str> The pony directories to use
''' '''
List.linklist(self.ponydirs if ponydirs is None else ponydirs, _list.linklist(self.ponydirs if ponydirs is None else ponydirs,
self.__quoters(), lambda x, y : self.__ucsise(x, y)) self.__quoters(), lambda x, y : self.__ucsise(x, y))
@ -760,7 +760,7 @@ 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
''' '''
List.onelist(self.ponydirs if standard else None, _list.onelist(self.ponydirs if standard else None,
self.extraponydirs if extra else None, self.extraponydirs if extra else None,
lambda x : self.__ucsise(x)) lambda x : self.__ucsise(x))
@ -801,7 +801,7 @@ class Ponysay():
''' '''
Prints a list of all balloons Prints a list of all balloons
''' '''
List.balloonlist(self.balloondirs, self.isthink) _list.balloonlist(self.balloondirs, self.isthink)
def __getBalloonPath(self, names, alt = False): def __getBalloonPath(self, names, alt = False):