aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-09-30 01:11:50 +0200
committerMattias Andrée <maandree@operamail.com>2012-09-30 01:11:50 +0200
commit0cd697f9464080371e8600ab4b05154165015820 (patch)
tree3eaffb141c45dcd9f83e4d474c4b2b87a3a8cad5
parent59247bf6e9c80e17fac4e58b80ad1bee1e602fa0 (diff)
downloadponysay-0cd697f9464080371e8600ab4b05154165015820.tar.gz
ponysay-0cd697f9464080371e8600ab4b05154165015820.tar.bz2
ponysay-0cd697f9464080371e8600ab4b05154165015820.zip
documenting the code
-rwxr-xr-xponysay.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/ponysay.py b/ponysay.py
index c1be5df..5f5afe9 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -502,20 +502,26 @@ class Ponysay():
Prints a list of all balloons
'''
def balloonlist(self):
+ ## Get the size of the terminal
termsize = self.__gettermsize()
- balloonset = set()
+ ## Get all balloons
+ balloonset = set()
for balloondir in balloondirs:
for balloon in os.listdir(balloondir):
+ ## Use .think if running ponythink, otherwise .say
if isthink and (len(balloon) > 6) and (balloon[-6:] == '.think'):
balloon = balloon[:-6]
elif (not isthink) and (len(balloon) > 4) and (balloon[-4:] == '.say'):
balloon = balloon[:-4]
else:
continue
+
+ ## Add the balloon if there is none with the same name
if balloon not in balloonset:
balloonset.add(balloon)
+ ## Print all balloos, columnised
self.__columnise([(balloon, balloon) for balloon in list(balloonset)])
@@ -523,29 +529,33 @@ class Ponysay():
Returns one file with full path, names is filter for style names, also accepts filepaths
'''
def __getballoonpath(self, names):
+ ## Stop if their is no choosen balloon
if names is None:
return None
- balloons = {}
+ ## Get all balloons
+ balloons = {}
for balloondir in balloondirs:
for balloon in os.listdir(balloondir):
balloonfile = balloon
+ ## Use .think if running ponythink, otherwise .say
if isthink and (len(balloon) > 6) and (balloon[-6:] == '.think'):
balloon = balloon[:-6]
elif (not isthink) and (len(balloon) > 4) and (balloon[-4:] == '.say'):
balloon = balloon[:-4]
else:
continue
+
+ ## Add the balloon if there is none with the same name
if balloon not in balloons:
balloons[balloon] = balloondir + balloonfile
+ ## Support for explicit balloon file names
for name in names:
if os.path.exists(name):
balloons[name] = name
- if names == None:
- names = list(balloons.keys())
-
+ ## Select a random balloon of the choosen ones
balloon = names[random.randrange(0, len(names))]
if balloon not in balloons:
sys.stderr.write('That balloon style %s does not exist\n' % (balloon));