mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 04:27:58 +01:00
list.py: Moved static functions to module level.
This commit is contained in:
parent
5e87dadc02
commit
69461d20fc
2 changed files with 217 additions and 224 deletions
33
src/list.py
33
src/list.py
|
@ -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 ‘$$$’
|
||||
lines and the ‘FREE’ is and upper case and directly followed by
|
||||
the colon.
|
||||
|
||||
|
||||
File listing functions.
|
||||
'''
|
||||
|
||||
|
||||
from ucs import *
|
||||
|
||||
|
||||
|
||||
class List():
|
||||
'''
|
||||
File listing functions
|
||||
'''
|
||||
|
||||
@staticmethod
|
||||
def __columnise(ponies):
|
||||
def _columnise(ponies):
|
||||
'''
|
||||
Columnise a list and prints it
|
||||
|
||||
|
@ -92,8 +90,7 @@ class List():
|
|||
print()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def simplelist(ponydirs, quoters = [], ucsiser = None):
|
||||
def simplelist(ponydirs, quoters = [], ucsiser = None):
|
||||
'''
|
||||
Lists the available ponies
|
||||
|
||||
|
@ -119,11 +116,10 @@ class List():
|
|||
if len(ponies) == 0:
|
||||
continue
|
||||
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
|
||||
|
||||
|
@ -197,11 +193,10 @@ class List():
|
|||
ponies[(item.replace('\033[1m', '').replace('\033[21m', ''), item)] = w
|
||||
|
||||
## 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
|
||||
|
||||
|
@ -237,8 +232,7 @@ class List():
|
|||
print(pony)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def balloonlist(balloondirs, isthink):
|
||||
def balloonlist(balloondirs, isthink):
|
||||
'''
|
||||
Prints a list of all balloons
|
||||
|
||||
|
@ -265,5 +259,4 @@ class List():
|
|||
balloonset.add(balloon)
|
||||
|
||||
## Print all balloos, columnised
|
||||
List.__columnise([(balloon, balloon) for balloon in list(balloonset)])
|
||||
|
||||
_columnise([(balloon, balloon) for balloon in balloonset])
|
||||
|
|
|
@ -35,7 +35,7 @@ from balloon import *
|
|||
from spellocorrecter import *
|
||||
from ucs import *
|
||||
from kms import *
|
||||
from list import *
|
||||
import list as _list
|
||||
from metadata import *
|
||||
|
||||
|
||||
|
@ -739,7 +739,7 @@ class Ponysay():
|
|||
|
||||
@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))
|
||||
|
||||
|
||||
|
@ -749,7 +749,7 @@ class Ponysay():
|
|||
|
||||
@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))
|
||||
|
||||
|
||||
|
@ -760,7 +760,7 @@ class Ponysay():
|
|||
@param standard:bool Include standard 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,
|
||||
lambda x : self.__ucsise(x))
|
||||
|
||||
|
@ -801,7 +801,7 @@ class Ponysay():
|
|||
'''
|
||||
Prints a list of all balloons
|
||||
'''
|
||||
List.balloonlist(self.balloondirs, self.isthink)
|
||||
_list.balloonlist(self.balloondirs, self.isthink)
|
||||
|
||||
|
||||
def __getBalloonPath(self, names, alt = False):
|
||||
|
|
Loading…
Reference in a new issue