View Single Post
Old 01-07-2018, 04:01 PM   #8
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: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by annoywife View Post
At the risk of overstaying my welcome in this thread, one final clarification: what's the right way to get a list of all possible preference names that I could pass to "db.pref()" such that, in the future, I could determine the calibre name for the specific preference I want? The initial answer above mentions looking at a preferences table - is this something that I would/should do using my new_api db object somehow?
I think you are going down a rat hole with this. There is no way to get a list of "all possible preference names" because the existence of a preference in calibre does not mean that the preference has a value -- is entered into the prefs dict. Looking at the defined preferences only tells you which of them has been set, not which of them could be set. In addition, simply knowing the name does not tell you what it actually means. I think you would be better served by determining if a preference is of interest by examining the GUI and the source code related to what you are interested in.

That said, this snippet will give you the names of all the library-specific preferences. Personally I think it is easier to look at the db using some db explorer (I use SQLiteSpy) because that lets you explore the values of the preferences in addition to the names. And yes, this snippet uses the old API.
Code:
from calibre.db.legacy import LibraryDatabase
db = LibraryDatabase(sys.argv[1])
all_prefs = db.prefs.iterkeys()
for t in all_prefs:
	print t
chaley is offline   Reply With Quote