diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-08-21 16:20:29 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-08-21 16:20:29 +0200 |
commit | 504a6bd5f5a13d19fee54fcbec537bdab983e2ba (patch) | |
tree | 775920b76881e597691a0c0f39632916902e3290 /ponysay | |
parent | 2934997c06b582dbbd7730555c9eecf817e5a035 (diff) | |
download | ponysay-504a6bd5f5a13d19fee54fcbec537bdab983e2ba.tar.gz ponysay-504a6bd5f5a13d19fee54fcbec537bdab983e2ba.tar.bz2 ponysay-504a6bd5f5a13d19fee54fcbec537bdab983e2ba.zip |
balloon stuff + pony names supersedes file names
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 41 |
1 files changed, 35 insertions, 6 deletions
@@ -70,17 +70,17 @@ class Ponysay(): def __getponypath(self, names = None): ponies = {} - if not names == None: - for name in names: - if os.path.isfile(name): - ponies[name] = name - for ponydir in ponydirs: for ponyfile in os.listdir(ponydir): pony = ponyfile[:-5] if pony not in ponies: ponies[pony] = ponydir + ponyfile + if not names == None: + for name in names: + if os.path.isfile(name): + ponies[name] = name + if names == None: names = list(ponies.keys()) @@ -289,6 +289,35 @@ class Ponysay(): ## ''' + Returns one file with full path, names is filter for names, also accepts filepaths + ''' + def __getballoonpath(self, names): + if names is None: + return None + balloons = {} + + for balloondir in balloondirs: + for balloonfile in os.listdir(balloondir): + balloon = balloonfile[:-5] + if balloon not in balloons: + balloons[balloon] = balloondir + balloonfile + + for name in names: + if os.path.isfile(name): + balloons[name] = name + + if names == None: + names = list(balloons.keys()) + + balloon = names[random.randrange(0, len(names))] + if balloon not in balloons: + sys.stderr.write('That balloon style %s does not exist\n' % (balloon)); + exit(1) + else: + return balloons[balloon] + + + ''' Creates the balloon style object ''' def __getballoon(self, balloonfile): @@ -1299,7 +1328,7 @@ pipelinein = not sys.stdin.isatty() ''' Whether stdout is piped ''' -pipelineout = False #not sys.stdout.isatty() # currently impossible, we need to get rid of the little shell script first +pipelineout = not sys.stdout.isatty() ''' Whether stderr is piped |