View Single Post
Old 11-27-2014, 02:29 AM   #17
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
P.S. chaley, thanks for the similar python script you created in the templates, plugboards, custom columns thread a while back, you helped me figure out how to interface with calibre.
Does this look good?
Looks mostly good.

Some comments:
- Why did you create the temp file for the txt format instead of simply using its path? EDIT: ahhh, I see. You created an empty txt file to avoid the necessity of passing one in as an argument or having one sitting around.
- You should first get the IDs that don't have a TXT format and add it only to them. Use something like cache.search('not formats:=TXT'). This is where the user could also add some criteria, such as doing it only if a book has a certain tag.
- You might want to put try/except around the add_format
- Is it worth checking add_format's returned value and printing an error?

Last edited by chaley; 11-27-2014 at 05:44 AM.
chaley is offline   Reply With Quote