View Single Post
Old 04-04-2018, 07:23 AM   #11
Dopedangel
Wizard
Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.
 
Dopedangel's Avatar
 
Posts: 1,794
Karma: 30548723
Join Date: Dec 2006
Location: Singapore
Device: Boyue
Quote:
Originally Posted by chaley View Post
This inspires me to give you a solution. You can use a custom template function in a "column built from other columns".

The steps:
  1. Create the template function by going to Preferences / Advanced / Template Functions.
  2. Give the template a name. In this example I named it length_of_longest_author.
  3. Put a -1 in the Argument count box because the function takes no arguments.
  4. Put this text in the Program code box:
    Code:
    def evaluate(self, formatter, kwargs, mi, locals):
    	authors = mi.get('authors')
    	if authors:
    		return max([len(a) for a in authors])
    	return 0
    The following screen capture shows the example
    Attachment 163238
  5. Create a custom column "built from other columns. Name it whatever you want. Set the template to
    Code:
    program: length_of_longest_author()
    using the name you used for the custom template function. Set the Sort/Search box to "Number". Check the "Show in Tag browser" box if you want to see the values in the tag browser. The following screen capture shows my example.
    Attachment 163239
It will be interesting to see what performance this has on your large library.
That was my thought as well the performance hit using dynamic columns could be very large. Modifying the word count plugin to count author name size would be I think faster plus as the op needs the count for 1 time cleaning only wont require the columns to be updated with each author change.
Dopedangel is offline   Reply With Quote