Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-08-2020, 02:21 PM   #1
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 78,914
Karma: 143095300
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Conversion to Python 3

There are a number of plugins where thh person who created them is no longer active and in the case of Modify ePub, Rev. Bob has said he doesn't know Python 3.

So is anyone willing step up and help do some conversion so these plugins can still be used come Calibre 4.99/5?

I don't know Python so I'm not able to help other then maybe to test.
JSWolf is offline   Reply With Quote
Old 01-08-2020, 05:19 PM   #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: 12,313
Karma: 7957679
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Starting in Feb I have some time to look at this issue. No guarantees: I also don't know P3 (but I trust I can learn what I need to know), have no interest in some plugins, and some others might be too opaque. Of course I must first deal with my own ...

I suggest that people propose here moribund-but-used plugins and see if anyone signs up.
chaley is offline   Reply With Quote
Old 01-08-2020, 06:29 PM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,598
Karma: 29709834
Join Date: Mar 2012
Location: Sydney Australia
Device: none
See List of PIs to be ported to Python 3

BR
BetterRed is offline   Reply With Quote
Old 01-08-2020, 06:33 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 78,914
Karma: 143095300
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by BetterRed View Post
One very much used plugin that's not yet been ported to Python 3 that's not in the list is the DeDRM plugin. Would someone like to take this on?
JSWolf is offline   Reply With Quote
Old 01-08-2020, 06:55 PM   #5
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,998
Karma: 89771343
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Quote:
Originally Posted by JSWolf View Post
One very much used plugin that's not yet been ported to Python 3 that's not in the list is the DeDRM plugin. Would someone like to take this on?
That is probably best discussed on Apprentice Harper's GitHub. Any USA-based developers may want to be cautious about openly violating the DMCA's prohibition on developing DRM removal software.
jhowell is offline   Reply With Quote
Old 01-08-2020, 06:59 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 78,914
Karma: 143095300
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by jhowell View Post
That is probably best discussed on Apprentice Harper's GitHub. Any USA-based developers may want to be cautious about openly violating the DMCA's prohibition on developing DRM removal software.
I did bring it up in the comments section of the blog and so far nobody has taken up the job. I'm hoping by mentioning it here that someone will take up the job. And just because the job is taken up by someone here doesn't mean that whoever does it has to say he/she was the one who did it.

Besides, DRM violates DMCA.
JSWolf is offline   Reply With Quote
Old 01-08-2020, 07:15 PM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,335
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JSWolf View Post
Besides, DRM violates DMCA.
Stop being obtuse. It does no such thing. And it's completely irrelevant to your request, to boot.
DiapDealer is offline   Reply With Quote
Old 01-08-2020, 07:18 PM   #8
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,998
Karma: 89771343
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Quote:
Originally Posted by JSWolf View Post
I did bring it up in the comments section of the blog and so far nobody has taken up the job.
If you look at the GitHub pull requests you will see that someone did some Python 3 work in November, but nothing ever happened with it. Which brings up another issue, Apprentice Harper appears to have abandoned that project.


Quote:
Originally Posted by JSWolf View Post
Besides, DRM violates DMCA.
Huh?
jhowell is offline   Reply With Quote
Old 01-09-2020, 02:21 AM   #9
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by chaley View Post
Starting in Feb I have some time to look at this issue. No guarantees: I also don't know P3 (but I trust I can learn what I need to know), have no interest in some plugins, and some others might be too opaque. Of course I must first deal with my own ...

I suggest that people propose here moribund-but-used plugins and see if anyone signs up.
I think it will be the same as what happened for Qt5. We'll fix our own plugins, then fix the ones we use. I have been maintaining a few of kiwidude's, so will do those. And @JimmXinu has been doing the same. But, I'm not in any hurry. Kovid said it would be the middle of the year before the release. I'll do them when I feel like it. Or am doing something else in the plugins.

I'll admit to not knowing Python 3 as well. I have read a couple of brief things, but, I'm following the BFI* method. Start in debug mode, look at the errors for a plugin, fix them, try again. Repeat until it loads. Then test the function and repeat. Then move onto the next plugin. But, apply the changes I did before.

There are a few things I know. For example, all the metadata source plugins I am replacing:
Code:
from urllib.parse import quote, unquote
from urllib import quote, unquote
with:
Code:
try:
    from urllib.parse import quote, unquote
except ImportError:
    from urllib import quote, unquote
try:
    from queue import Empty, Queue
except ImportError:
    from Queue import Empty, Queue
import six
from six import text_type as unicode
That should keep backwards compatibility. With some removals and additions as needed.

Then, any "prints" have to be changed to wrap parentheses around the argument. So, instead of:

Code:
print "The code shouldn't have reached here"
it is:

Code:
print("The code shouldn't have reached here")
Another one I found was:

Code:
except Exception, e:
which should be:

Code:
except Exception as e:
Other changes are:
  • use "items" instead of "iteritems" - Works in 2.7 but, could be slower. Luckily, I'm only using it on small numbers of items.
  • "if whatever is None" rather than "if whatever" - I've been gradually converting this anyway as I prefer it.

If anyone can see a problem with these suggestions, or has a good list of other things to look for, I'd be happy to see it.


(*Brute force and ignorance)
davidfor is offline   Reply With Quote
Old 01-09-2020, 08:14 AM   #10
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: 45,144
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@davidfor Run 2to3 it will print out a diff of all the problems it finds which is a convenient way to see what to change. After that grep for bytes, encode and decode that should cover most things.
kovidgoyal is offline   Reply With Quote
Old 01-09-2020, 10:21 AM   #11
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Simultaneously Supporting Calibre 4.6 & 4.99: Cheat Sheet

I've ported 14 of my 15 GUI plugins such that they are simultaneously compatible with Calibre 4.6 and 4.99.3. During that tedious, lengthy and sometimes painful journey, I kept a list of frequent solutions to problems I encountered. I hope this helps folks.


Code:
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

from polyglot.builtins import as_bytes, as_unicode, codepoint_to_chr, is_py3, iteritems, map, only_unicode_recursive, range, unicode_type

from polyglot.io import PolyglotStringIO  

if is_py3:
    from queue import Queue
else:
    from Queue import Queue

for k,v in iteritems(my_dict):


from calibre.utils.serialize import json_dumps, json_loads  


if is_py3:
      from html.parser import HTMLParser as myhtmlparser    
else:
    import HTMLParser 
    myhtmlparser = HTMLParser.HTMLParser

                 
if is_py3:
    from urllib.request import urlopen
    from urllib.parse import urlencode 
else:
    from urllib import urlencode
    from urllib2 import urlopen


if is_py3:
    my_list = as_unicode(my_list)
else:
    my_list = as_bytes(my_list)
my_list = ast.literal_eval(my_list)

if not isinstance(text,unicode_type):        #unicode is a Py2 type; use Polyglot's unicode_type instead. 
     

You will see a lot of these errors:
TypeError: a bytes-like object is required, not 'str'
TypeError: can only concatenate str (not "bytes") to str 


Py3 redefined what a bytestring is internally:
The bytestring 'A' is this in Python 2:  A
the bytestring 'A' is this in Python 3:   (a 3 digit integer)
Python2 was very forgiving and helpful in converting bytestrings to and from unicode when, for example, concatenating them. It just did it silently, and was unknowingly taken for granted.

Python3 is not at all forgiving and not at all helpful in converting anything to anything. Hence, errors such as: 'TypeError: can only concatenate str (not "bytes") to str' will happen if you try to concatenate text with, for example, a bytes version of an integer. Ditto for doing a str.replace(x,y); both x and y must be strings, not bytestrings, since a str in Py3 is an instance of 'str', not 'bytes'.



DaltonST

Last edited by DaltonST; 01-09-2020 at 12:32 PM. Reason: Tips
DaltonST is offline   Reply With Quote
Old 01-09-2020, 04:02 PM   #12
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,812
Karma: 4604429
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
Quote:
Originally Posted by davidfor View Post
I think it will be the same as what happened for Qt5. We'll fix our own plugins, then fix the ones we use. I have been maintaining a few of kiwidude's, so will do those. And @JimmXinu has been doing the same. But, I'm not in any hurry. Kovid said it would be the middle of the year before the release. I'll do them when I feel like it. Or am doing something else in the plugins.
Yeah, I leapt into it when the Kovid posted the py3 beta versions, but I felt a lot less urgency after that 'middle of the year' time frame came out.

Plus I've seen very little response to posting py3 plugin test versions.

That said, I do plan to release FanFicFare including the py3 changes in the next week or so. That's going to be my first canary.
JimmXinu is offline   Reply With Quote
Old 01-10-2020, 12:11 AM   #13
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Thank you very much to davidfor, kovigoyal and DaltonST for their comments about the conversion. I have some work to do myself and it will go a good way to begin.
Terisa de morgan is offline   Reply With Quote
Old 01-10-2020, 12:12 AM   #14
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by JimmXinu View Post
Plus I've seen very little response to posting py3 plugin test versions.
I think that, mainly, as there is no change in calibre or the plugin, no urgency to test. Some days before the change, if it is announced, the rush will begin.
Terisa de morgan is offline   Reply With Quote
Old 01-10-2020, 02:07 AM   #15
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Terisa de morgan View Post
I think that, mainly, as there is no change in calibre or the plugin, no urgency to test. Some days before the change, if it is announced, the rush will begin.
There is no way that that would happen. I'm sure no-one here stayed up all night to finish their school assignments. Or to study for an exam. I'm sure we all carefully plan things out so that it's all completed well ahead of time so we can relax and do other things. I'm sure that no-one here has ever explained to a Project Manager that when they said "the end of the week" they meant "Friday at 81 o'clock".


And the above was written with my tongue firmly in my cheek
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python 2 to Python 3, Polyglot & Plugins DaltonST Calibre 18 04-24-2019 12:10 AM
Is there any Python API for file conversion? avin Development 0 12-27-2016 08:11 AM
"Python function terminated unexpectedly" on ePub to PDF conversion zunga Conversion 10 03-17-2013 07:18 PM
python based pdf conversion tools KevinH Conversion 1 01-23-2011 11:39 AM
Import ebook conversion in python script erollisi Calibre 1 08-19-2010 09:43 PM


All times are GMT -4. The time now is 12:57 AM.


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