Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 02-24-2011, 03:38 AM   #1
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
JSONConfig has no delete method

JSONConfig in utils/config.py allows set/get but not delete of a specific key. Is it possible to delete a key from a plugin's json file?

Normally I don't need this, but I'm renaming a key and the only way I found to 'remove' the old key is to set the old key value to Null.

This is sufficient, although it leaves old/unused data in the file, and it means an extra test is needed since the key exists but the data is Null (since get(store_name, DEFAULTS) will not set the key to DEFAULTS if the key exists but is a dict with Null).
meme is offline   Reply With Quote
Old 02-24-2011, 06:21 AM   #2
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
JSONConfig inherits from XMLConfig, which does have a delete operation. Have you tried using "del json_object[key]"?
chaley is offline   Reply With Quote
Old 02-24-2011, 08:38 AM   #3
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
That was it, thanks. I've used the del statement elsewhere, and noticed that XMLConfig inherits from dict, but didn't connect using del on it would work like del for a dict. The del statement is a bit odd anyway since most everything else is called like a function - I was looking for a del() method and all I could see was __delitem__ (which given the __ I believe is an internal method).
meme is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Method for seeing only the recent imports peterloron Calibre 3 09-22-2010 04:02 PM
"cannot import name JSONConfig" on launching calibre .42 hakan42 Calibre 4 02-27-2010 03:37 AM
Delete files in PC not equal to delete in Sony reader 505 sheilalayoli Sony Reader 5 07-12-2009 03:13 PM
Library management - your method? thfc2008 Sony Reader 1 10-28-2008 10:24 AM
alternate login method? curtw Feedback 9 04-23-2008 11:05 PM


All times are GMT -4. The time now is 07:22 PM.


MobileRead.com is a privately owned, operated and funded community.