Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-24-2022, 05:01 PM   #121
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by thiago.eec View Post
I think the post is about this key:
'is_custom' : False
Yes, exactly.

I have seen in the code comments/doc that the label is the raw name of the column, the prefix being applied only later, which must that
Code:
if self.is_custom:
        return '#' + self.label
else:
        return self.label
so when during my test I saw {"custom_series_index" : 77} appear, I was a little surprised.
However, on the GUI side, Yes, all works and the name is well prefixed

Well, it's only very marginal and obscure, and plugins like 'Manage Series' modify its fields without case. So I think somewhere along the way there and back, we lost a part without realizing it, since the car still runs perfectly. Oops?

Last edited by un_pogaz; 01-24-2022 at 05:06 PM.
un_pogaz is offline   Reply With Quote
Old 01-24-2022, 05:09 PM   #122
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,728
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
Code:
if self.is_custom:
        return '#' + self.label
else:
        return self.label
Field metadata is a python dict. The key is the one-true lookup name. You will see this if you do something like
Code:
        for k,v in db.field_metadata.items():
            print(k, v)
chaley is offline   Reply With Quote
Old 01-24-2022, 05:14 PM   #123
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,085
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
That is because series indices aren't real columns, custom or otherwise. Every series-type column 'lookup_name' has an associated virtual column 'lookup_name_index', added automatically when the series-type column is added to field metadata. The value of that virtual column comes either from the book record (series) or from the series link table (#series).
I had an Action Chains template function that needed the is_custom to return true for custom_series_index virtual columns. So I, foolishly, made a function that modified the dictionary, forgetting to make a deepcopy of the object beforehand. It backfired spectacularly .
capink is offline   Reply With Quote
Old 01-25-2022, 05:25 AM   #124
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Released 5.99.4 which fixes reported issues and also implements automatic dark/light mode transition on Windows. Now if you change the system theme calibre will change along with it. This was already implemented for macOS now windows has it too.
kovidgoyal is online now   Reply With Quote
Old 01-25-2022, 06:08 AM   #125
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
Well, that such an "error" since V2 (I checked) seems to me aberrant.
We're talking about Calibre, it's monstrous. There must be a reason.

After a lot of thinking, I came to the conclusion that this "inconsistency" was there to detect the series indexes, like this:
Code:
is_float
    cc.label == 'size' or data['datatype'] == 'float' and cc.is_custom and cc.label != 'series_index'

is_series_index
    cc.label == 'series_index' or data['datatype'] == 'float' and not cc.is_custom and not cc.label == 'size')
this code allows to filter between "true" float (that alone) and the "series_index" float associated to a series.

And to get the name (with prefix of custom), we need to make something a little bigger
Code:
if self.is_custom or cc.is_float and cc.label not in ['size', 'series_index']:
    return '#' + self.label
else:
    return self.label
... or maybe, not. I'm looking at the FieldMetadata code, and the real detection of it's is a custom field is done on the 'key' of the dictionary it was in, not on the FieldMetadata object itself.
'key' created previously, in a different context with differents functions.
So if you ever iterate all the field on GUI.db.field_metadata but only process the value (like .values() ), poof, your lost the TRUE identifier of this is a custom.
...
Finally, if it's really a bug/blunder: No, don't fixe it.
Do like all dev:
It's not a bug, it's a feature *magic*.

Because otherwise we will not be able to detect if the field is a "true" float or a series_index, as I just did.
And I will modify my code to have a private bool that will remember that a custom custom, it will be easier.

Last edited by un_pogaz; 01-25-2022 at 06:17 AM.
un_pogaz is offline   Reply With Quote
Old 01-25-2022, 08:47 AM   #126
lomkiri
Zealot
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 131
Karma: 1000102
Join Date: Jul 2021
Device: N/A
Hi, Kovid,

calibre 5.99.4
In a plugin using your Dialog class (from calibre.gui2.widgets2 import Dialog), I still get the error you just corrected in the post 110.
After some debug of my code, I found that it is because I use bytearray(self.saveGeometry()) in a dict of dict, instead of a simple dict.
I don't know if it worth for you to correct it, in anycase I can work this around easily.

example of code :
Code:
self.windoPos = {}
self.windowPos['geometry'] = bytearray(self.saveGeometry())
gui_prefs.set('main_window', self.windowPos)
gives this exception:
Spoiler:
File "calibre_plugins.typex.dialogs", line 110, in closeEvent
gui_prefs.set('main_window', self.windowPos)
File "calibre/utils/config.py", line 383, in set
File "calibre/utils/config.py", line 438, in __setitem__
File "calibre/utils/config.py", line 401, in commit
File "calibre/utils/config.py", line 422, in to_raw
File "calibre/utils/config_base.py", line 100, in json_dumps
File "json/__init__.py", line 238, in dumps
File "json/encoder.py", line 201, in encode
File "json/encoder.py", line 431, in _iterencode
File "json/encoder.py", line 405, in _iterencode_dict
File "json/encoder.py", line 405, in _iterencode_dict
File "json/encoder.py", line 438, in _iterencode
File "calibre/utils/config_base.py", line 53, in to_json
TypeError: <DockWidgetArea.NoDockWidgetArea: 0> is not JSON serializable

With calibre 5.32, it's working OK and gives this structure in the json:
Spoiler:
Code:
  "main_window": {
    "dockarea": 0,
    "floating": true,
    "geometry": {
      "__class__": "bytearray",
      "__value__": "AdnQywADAAAAAAKjAAABhQAABYoAAALIAAACowAAAYUAAAWKAAACyAAAAAAAAAAAB4AAAAKjAAABhQAABYoAAALI"
    }
  }

If i change the code to
Code:
gui_prefs.set('main_window' + '-geometry', bytearray(self.saveGeometry()))
I get no exception anymore (in 5.99.4), so the work around would be easy if this case a too particular one to be fixed.

Thank you!

Last edited by lomkiri; 01-25-2022 at 08:51 AM.
lomkiri is offline   Reply With Quote
Old 01-25-2022, 08:59 AM   #127
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont think thats because of geometry, its because of the dockarea being an enum which is not JSON serializable. what you need to do is

self.windowPos['dockarea'] = whatever.value
kovidgoyal is online now   Reply With Quote
Old 01-25-2022, 10:19 AM   #128
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
New kiwidude icons loader

Quote:
Originally Posted by kovidgoyal View Post
s of 5.99.3 the betas have support for proper icon themeing with support for using different icon themes for light and dark mode and calibre switches between them automatically. [...] Note that if you use kiwidude's code for loading icons, you will need to adjust it, as the way it loads themed icons will no longer work.
I just saw this, so I tried to modify the kiwidude loader to make a version that can handle the OS theme change.

All you need to do to make it compatible is, inside the genesis function add self.plugin_path as second argument.
Code:
set_plugin_icon_resources(self.name, self.plugin_path, resources=[])
The theme OS icons will be located in a sub-folder of the actual images folder "images/", "images/dark/", "images/light/".

I can't try to change the theme of my PC, so if anyone is willing to give me feedback.
Thanks you

EDIT: Oops, first try, fail. I re-up a new version that work really.
Attached Files
File Type: py themed_icon_kiwi.py (4.5 KB, 68 views)

Last edited by un_pogaz; 01-25-2022 at 12:33 PM.
un_pogaz is offline   Reply With Quote
Old 01-25-2022, 02:32 PM   #129
lomkiri
Zealot
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 131
Karma: 1000102
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by kovidgoyal View Post
I dont think thats because of geometry, its because of the dockarea being an enum which is not JSON serializable. what you need to do is

self.windowPos['dockarea'] = whatever.value
Mmmh, sure, I didn't realized that the signal dockLocationChanged was now passing an enum, not anymore a value.
Thanks for pointing it, it is now working (but I had to include a test "is_pyqt5", since it cannot be the same code for qt5 and qt6)
I wonder what was the pleasure for the PyQt team to complicate the things that much.
lomkiri is offline   Reply With Quote
Old 01-26-2022, 10:12 AM   #130
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,085
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
I am not able to open the manage authors dialog. Getting this error:

Spoiler:

calibre, version 5.99.4
ERROR: Unhandled exception: <b>TypeError</b>:QTableView.sortByColumn(): argument 2 has unexpected type 'int'

calibre 5.99.4 embedded-python: True
Linux-5.13.0-27-generic-x86_64-with-glibc2.34 Linux ('64bit', 'ELF')
('Linux', '5.13.0-27-generic', '#29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022')
Python 3.10.1
Interface language: None
Successfully initialized third party plugins: Action Chains (1, 16, 0) && Category Tags (0, 2, 2) && Editor Chains (0, 5, 0) && Favourites Menu (1, 1, 0) && Find Duplicates (1, 9, 2) && Goodreads (1, 5, 3) && Import List (1, 8, 1) && Last Modified (0, 8, 1) && Manage Series (1, 3, 0) && View Manager (1, 7, 0)
Traceback (most recent call last):
File "calibre/gui2/tag_browser/ui.py", line 446, in do_author_sort_edit
File "calibre/gui2/dialogs/edit_authors_dialog.py", line 171, in __init__
File "calibre/gui2/dialogs/edit_authors_dialog.py", line 222, in show_table
File "calibre/gui2/dialogs/edit_authors_dialog.py", line 427, in do_sort_by_author_sort
TypeError: QTableView.sortByColumn(): argument 2 has unexpected type 'int'

capink is offline   Reply With Quote
Old 01-26-2022, 10:17 AM   #131
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
this should take care of it: https://github.com/kovidgoyal/calibr...0e5714db3fac8b
kovidgoyal is online now   Reply With Quote
Old 01-26-2022, 10:26 AM   #132
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,085
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Thanks for the quick fix.
capink is offline   Reply With Quote
Old 01-26-2022, 05:12 PM   #133
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 680
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
Related to Qt6.
Attached Thumbnails
Click image for larger version

Name:	calibre-5-99-4-stretch.png
Views:	124
Size:	73.8 KB
ID:	191909  
BeckyEbook is offline   Reply With Quote
Old 01-26-2022, 09:15 PM   #134
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...b700979c05fe7a
kovidgoyal is online now   Reply With Quote
Old 02-01-2022, 02:29 PM   #135
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,198
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
In the Editor I tried to use Compare > Options > Beautify files before compare and got this error message:
Code:
calibre, version 5.99.4
ERROR: Unhandled exception: <b>TypeError</b>:QTextDocument.setPlainText(): argument 1 has unexpected type 'bytes'

calibre 5.99.4 Portable embedded-python: True
Windows-10-10.0.19042 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19042')
Python 3.10.1
Windows: ('10', '10.0.19042', '', 'Multiprocessor Free')
Interface language: en_GB
Successfully initialized third party plugins: Device Old Books (0, 6, 0) && Epub2Kepub (0, 1, 0) && EpubCheck (0, 2, 4) && EpubMetadata (0, 1, 0) && EpubModBuild (0, 1, 0) && EpubXCustomMetadata (0, 1, 0) && JS_Editor_Tools (0, 6, 0) && JS_Editor_Utils (0, 1, 0) && JS_Modify_Epub (0, 1, 0) && KePub Input (3, 4, 3) && KePub Metadata Reader (3, 4, 3) && KePub Metadata Writer (3, 4, 3) && KindleUnpack - The Plugin (0, 83, 1) && Kobo Utilities (2, 15, 1) && KoboEject (0, 0, 3) && KoboTouchExtended (3, 5, 4) && Obok DeDRM (7, 2, 99) && ScrambleEbook (0, 5, 3) && Smart_Device_App_CSSAdd (0, 0, 12) && TTS to MP3 (0, 6, 0)
Traceback (most recent call last):
  File "calibre\gui2\tweak_book\diff\main.py", line 350, in toggle_beautify
  File "calibre\gui2\tweak_book\diff\main.py", line 344, in refresh
  File "calibre\gui2\tweak_book\diff\view.py", line 554, in add_diff
  File "calibre\gui2\tweak_book\diff\view.py", line 691, in add_text_diff
  File "calibre\gui2\tweak_book\diff\highlight.py", line 117, in get_highlighter
  File "calibre\gui2\tweak_book\diff\highlight.py", line 27, in __init__
TypeError: QTextDocument.setPlainText(): argument 1 has unexpected type 'bytes'
ETA: It looks like the same error also exists in v5.35.

Last edited by jackie_w; 02-01-2022 at 02:42 PM. Reason: ETA
jackie_w is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion for PI Devs BetterRed Plugins 11 09-27-2020 06:18 PM
Attn plugin devs: porting to python 3 kovidgoyal Plugins 129 06-16-2020 01:31 AM
Attention All Plugin Devs: Remove vestiges from python 2? KevinH Plugins 11 05-29-2020 03:16 PM
Plugin Devs: Should we include a License or COPYING file? KevinH Plugins 3 08-15-2017 01:09 PM
New Plugin Features in the upcoming Sigil 0.8.900 KevinH Plugins 6 09-14-2015 02:48 PM


All times are GMT -4. The time now is 12:10 PM.


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