From cbbb9be76c7ab4d7bec9c7f7afea3dda8fd949b6 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 22 Aug 2012 15:50:42 +0200 Subject: Non-TV ponies --- ponysay | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 9fc8c70..62f6834 100755 --- a/ponysay +++ b/ponysay @@ -58,14 +58,24 @@ class Ponysay(): else: self.__bestpony(args) self.__ucsremap(args) + self.__extraponies(args) if args.opts['-q'] is not None: self.quote(args) else: self.print_pony(args) ## - ## Auxiliary methods + ## Methods that run in the beginning of non-listing and non-help stuff ## + ''' + Use best.pony if nothing else is set + ''' + def __bestpony(self, args): + if args.opts['-F'] is not None: + args.opts['-f'] = args.opts['-F'] + ponydirs = extraponydirs + + ''' Use best.pony if nothing else is set ''' @@ -118,6 +128,10 @@ class Ponysay(): args.opts[flag][i] = map[args.opts[flag][i]] + ## + ## Auxiliary methods + ## + ''' Apply USC:ise pony names according to UCS settings ''' @@ -1596,6 +1610,12 @@ Whether stderr is piped pipelineerr = not sys.stderr.isatty() +''' +Whether KMS is used +''' +usekms = Ponysay.isUsingKMS() + + ''' Root share/ directories ''' @@ -1607,17 +1627,27 @@ for sharedir in _sharedirs: ''' -The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) +The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS ''' ponydirs = [] -_kms = Ponysay.isUsingKMS() -if linuxvt and not _kms: _ponydirs = [d + 'ttyponies/' for d in sharedirs] -else: _ponydirs = [d + 'ponies/' for d in sharedirs] +if linuxvt and not usekms: _ponydirs = [d + 'ttyponies/' for d in sharedirs] +else: _ponydirs = [d + 'ponies/' for d in sharedirs] for ponydir in _ponydirs: if os.path.isdir(ponydir): ponydirs.append(ponydir) +''' +The directories where pony files are stored, extrattyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS +''' +extraponydirs = [] +if linuxvt and not usekms: _extraponydirs = [d + 'extrattyponies/' for d in sharedirs] +else: _extraponydirs = [d + 'extraponies/' for d in sharedirs] +for extraponydir in _extraponydirs: + if os.path.isdir(extraponydir): + extraponydirs.append(extraponydir) + + ''' The directories where quotes files are stored ''' @@ -1638,11 +1668,11 @@ for balloondir in _balloondirs: balloondirs.append(balloondir) -usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m' -usage_common = '[-c] [-W \033[4mCOLUMN\033[24m] [-b \033[4mSTYLE\033[24m]' -usage_listhelp = '(-l | -L | -B | -v | -h)' -usage_file = '[-f \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' -usage_quote = '-q [\033[4mPONY\033[24m...]' +usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m' +usage_common = '[-c] [-W \033[4mCOLUMN\033[24m] [-b \033[4mSTYLE\033[24m]' +usage_listhelp = '(-l | -L | -B | -v | -h)' +usage_file = '[(-f | -F) \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' +usage_quote = '-q [\033[4mPONY\033[24m...]' usage = '%s %s\n%s %s %s\n%s %s %s' % (usage_saythink, usage_listhelp, usage_saythink, usage_common, usage_file, @@ -1677,6 +1707,7 @@ opts.add_argumentless(['-c', '--compact'], help = opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify the column when the message should be wrapped.') opts.add_argumented( ['-b', '--bubble', '--balloon'], arg = 'STYLE', help = 'Select a balloon style.') opts.add_argumented( ['-f', '--file', '--pony'], arg = 'PONY', help = 'Select a pony.\nEither a file name or a pony name.') +opts.add_argumented( ['-F', '++file', '++pony'], arg = 'PONY', help = 'Select a non-MLP:FiM pony.') opts.add_variadic( ['-q', '--quote'], arg = 'PONY', help = 'Select a ponies which will quote themself.') opts.parse() -- cgit From 243612379e077eb46159cb64df51de2489b5c67f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 22 Aug 2012 15:56:48 +0200 Subject: Non-TV ponies fix --- ponysay | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 62f6834..f4480c0 100755 --- a/ponysay +++ b/ponysay @@ -56,24 +56,24 @@ class Ponysay(): elif args.opts['-L'] is not None: self.linklist() elif args.opts['-B'] is not None: self.balloonlist() else: + self.__extraponies(args) self.__bestpony(args) self.__ucsremap(args) - self.__extraponies(args) if args.opts['-q'] is not None: self.quote(args) else: self.print_pony(args) ## - ## Methods that run in the beginning of non-listing and non-help stuff + ## Methods that run before the mane methods ## ''' - Use best.pony if nothing else is set + Use extra ponies ''' - def __bestpony(self, args): + def __extraponies(self, args): if args.opts['-F'] is not None: args.opts['-f'] = args.opts['-F'] - ponydirs = extraponydirs + ponydirs[:] = extraponydirs ''' @@ -1668,11 +1668,11 @@ for balloondir in _balloondirs: balloondirs.append(balloondir) -usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m' -usage_common = '[-c] [-W \033[4mCOLUMN\033[24m] [-b \033[4mSTYLE\033[24m]' -usage_listhelp = '(-l | -L | -B | -v | -h)' -usage_file = '[(-f | -F) \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' -usage_quote = '-q [\033[4mPONY\033[24m...]' +usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m' +usage_common = '[-c] [-W \033[4mCOLUMN\033[24m] [-b \033[4mSTYLE\033[24m]' +usage_listhelp = '(-l | -L | -B | -v | -h)' +usage_file = '[(-f | -F) \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' +usage_quote = '-q [\033[4mPONY\033[24m...]' usage = '%s %s\n%s %s %s\n%s %s %s' % (usage_saythink, usage_listhelp, usage_saythink, usage_common, usage_file, -- cgit From a84f1d6534515e3264b6e87d9f13568de98feade Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 22 Aug 2012 16:01:37 +0200 Subject: listing extra ponies --- ponysay | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index f4480c0..baea15c 100755 --- a/ponysay +++ b/ponysay @@ -55,6 +55,9 @@ class Ponysay(): elif args.opts['-l'] is not None: self.list() elif args.opts['-L'] is not None: self.linklist() elif args.opts['-B'] is not None: self.balloonlist() + elif args.opts['++onelist'] is not None: self.__extraponies(); self.onelist() + elif args.opts['+l'] is not None: self.__extraponies(); self.list() + elif args.opts['+L'] is not None: self.__extraponies(); self.linklist() else: self.__extraponies(args) self.__bestpony(args) @@ -70,8 +73,10 @@ class Ponysay(): ''' Use extra ponies ''' - def __extraponies(self, args): - if args.opts['-F'] is not None: + def __extraponies(self, args = None): + if args is None: + ponydirs[:] = extraponydirs + elif args.opts['-F'] is not None: args.opts['-f'] = args.opts['-F'] ponydirs[:] = extraponydirs @@ -1697,11 +1702,14 @@ run `man ponysay`. Ponysay has so much more to offer than described here.''') opts.add_argumentless(['--quoters']) opts.add_argumentless(['--onelist']) +opts.add_argumentless(['++onelist']) opts.add_argumentless(['-h', '--help'], help = 'Print this help message.') opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.') opts.add_argumentless(['-l', '--list'], help = 'List pony names.') opts.add_argumentless(['-L', '--altlist'], help = 'List pony names with alternatives.') +opts.add_argumentless(['+l', '++list'], help = 'List non-MLP:FiM pony names.') +opts.add_argumentless(['+L', '++altlist'], help = 'List non-MLP:FiM pony names with alternatives.') opts.add_argumentless(['-B', '--balloonlist'], help = 'List balloon styles.') opts.add_argumentless(['-c', '--compact'], help = 'Compress messages.') opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify the column when the message should be wrapped.') -- cgit From f830ba4cf7b21b50406fbccf32535ebda11c2ed9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 22 Aug 2012 16:25:35 +0200 Subject: misc --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index baea15c..67a7d2e 100755 --- a/ponysay +++ b/ponysay @@ -1675,7 +1675,7 @@ for balloondir in _balloondirs: usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m' usage_common = '[-c] [-W \033[4mCOLUMN\033[24m] [-b \033[4mSTYLE\033[24m]' -usage_listhelp = '(-l | -L | -B | -v | -h)' +usage_listhelp = '(-l | -L | -B | +l | +L | -v | -h)' usage_file = '[(-f | -F) \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' usage_quote = '-q [\033[4mPONY\033[24m...]' -- cgit From d3ddf64433b38558a4dc83eba36469a971dd9640 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 22 Aug 2012 16:36:47 +0200 Subject: final touches on extra ponies --- ponysay | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 67a7d2e..faca1d3 100755 --- a/ponysay +++ b/ponysay @@ -282,8 +282,6 @@ class Ponysay(): quoters = self.__quoters() for ponydir in ponydirs: # Loop ponydirs - print('\033[1mponies located in ' + ponydir + '\033[21m') - _ponies = os.listdir(ponydir) ponies = [] for pony in _ponies: @@ -292,6 +290,10 @@ class Ponysay(): self.__ucsise(ponies) ponies.sort() + if len(ponies) == 0: + continue + print('\033[1mponies located in ' + ponydir + '\033[21m') + width = UCS.dispLen(max(ponies, key = UCS.dispLen)) + 2 # Get the longest ponyfilename lenght + 2 spaces x = 0 @@ -314,13 +316,16 @@ class Ponysay(): quoters = self.__quoters() for ponydir in ponydirs: # Loop ponydirs - print('\033[1mponies located in ' + ponydir + '\033[21m') - _ponies = os.listdir(ponydir) ponies = [] for pony in _ponies: if (len(pony) > 5) and (pony[-5:] == '.pony'): ponies.append(pony[:-5]) + + if len(ponies) == 0: + continue + print('\033[1mponies located in ' + ponydir + '\033[21m') + pseudolinkmap = {} self.__ucsise(ponies, pseudolinkmap) ##TODO pairs = [] -- cgit