Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 10-20-2014, 02:56 AM   #1081
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by KevinH View Post
Yes that would be a good idea but I had not figured out how to push the historic release tags from my local tree to github yet, so there were no releases to link to when I made the post. I only found out how to do that today.
So I just was telling you what you already knew and was planning to use. Sorry for noise. Nice work with tagging!
eureka is offline   Reply With Quote
Old 10-20-2014, 03:17 AM   #1082
quiris
Groupie
quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'quiris understands when you whisper 'The dog barks at midnight.'
 
quiris's Avatar
 
Posts: 195
Karma: 42216
Join Date: Oct 2013
Location: Poland
Device: Kindles: KOA1, KV
Quote:
Originally Posted by quiris View Post
Is there an open github.com repository with KindleUnpack source code? It would be easier to track changes…
Quote:
Originally Posted by KevinH View Post
The url for the repository is:
https://github.com/kevinhendricks/KindleUnpack
At last… Thank you
quiris is offline   Reply With Quote
Advert
Old 10-20-2014, 04:43 AM   #1083
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by eschwartz View Post
Yep, basically you get a pretty icon and a clicky to your GitHub profile in the commit log plus credit here: https://github.com/kevinhendricks/Ki...kevinhendricks
And credit in contributors list.
eureka is offline   Reply With Quote
Old 10-20-2014, 02:58 PM   #1084
Peter Ahlstrom
Connoisseur
Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.Peter Ahlstrom ought to be getting tired of karma fortunes by now.
 
Posts: 75
Karma: 500000
Join Date: Oct 2011
Location: Utah
Device: iPad
Quote:
Originally Posted by KevinH View Post
Thank you so much for submitting your bug report and test case as it helps us to better understand the inner workings of the mobi format!
Great! Glad I was able to help.
Peter Ahlstrom is offline   Reply With Quote
Old 10-25-2014, 08:36 AM   #1085
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi Kevin,

I have fixed a bug in the python2and3 branch on the github.
In addition, I have modified to make eaier to compare the unpacked results by python 2 and python 3.

Take care,
Attached Files
File Type: zip python2and3.patch.zip (1.8 KB, 197 views)
tkeo is offline   Reply With Quote
Advert
Old 10-25-2014, 10:35 AM   #1086
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,733
Karma: 5444398
Join Date: Nov 2009
Device: many
Hi tkeo,
Do we really need to overwrite all dictionaries with ordered dictionaries?

I would prefer we explicitly use ordered dicts only where needed (and none are actually truly needed here ... ). If you have some justification as to why you need an ordered dict then import it as something other than dict and use it only where needed explicitly.

Also, the flake8 style checks require a space after the "#" for comments. Better yet simply delete those extra HtmlParser related lines since the compatibility_utils unescapeit removes their use completely.

If you can fix both of these and have a github account, please create a fork and pull request, so that you get the proper credit in the history.

Thanks,

Kevin

Last edited by KevinH; 10-25-2014 at 03:11 PM. Reason: updated now that I understand that dict() is a builtin for a normal dictionary
KevinH is offline   Reply With Quote
Old 10-26-2014, 04:45 AM   #1087
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi Kevin,


Quote:
Originally Posted by KevinH View Post
I would prefer we explicitly use ordered dicts only where needed (and none are actually truly needed here ... ). If you have some justification as to why you need an ordered dict then import it as something other than dict and use it only where needed explicitly.
I compare the unpacking results of two versions by a diff command or a GUI diff tool. Using the ordered dictionaries makes testing easier greatly. I have found the necessary dictionaryies to be needed keeping orders are metadata in mobi_header and tattr in mobi_k8resc.py for my demand.
So, could you change dict to OrderedDict if acceptable for you?

BTW, are there any case that keeping the oders of data in a mobi helps to understand the functionality of kindlegen better?

Quote:
If you can fix both of these and have a github account, please create a fork and pull request, so that you get the proper credit in the history.
I have made a new patch; but, I do not have any github account. Could you update it on my behalf?

Thanks,
Attached Files
File Type: zip python2and3.patch.zip (1.2 KB, 183 views)
tkeo is offline   Reply With Quote
Old 10-26-2014, 11:07 AM   #1088
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,733
Karma: 5444398
Join Date: Nov 2009
Device: many
Hi tkeo,

Do you understand that no xml parser guarantees order of attributes? The order of attributes simply does not matter when recreating the opf.

As for dumping the header, both DumpMobiHeader.py and the dump code in unpack will show you the order of the header values, the exth, and all of the sections themselves if you enable debug.

So neither of your use cases makes any sense.

Using an ordered dict to maintain order when no xml parser needs it just hurts execution time meaninglessly. An ordered dict actually requires a normal dict plus a doubly linked list, plus a second ordered dict to quickly find elements in the doubly linked list. All of that in unneccessary overhead for something that does not matter to any xml processor.

So I will not integrate an ordered dict patch unless you can explain why it is truly needed. If it is only so you can diff things, then incorporate its use into a DEBUG setting to enable it only when DEBUG is true, otherwise use normal dictionaries.

Hope this better explains things.

KevinH

ps. I have committed your bug fix for removal of HTMLParser

Quote:
Originally Posted by tkeo View Post
Hi Kevin,



I compare the unpacking results of two versions by a diff command or a GUI diff tool. Using the ordered dictionaries makes testing easier greatly. I have found the necessary dictionaryies to be needed keeping orders are metadata in mobi_header and tattr in mobi_k8resc.py for my demand.
So, could you change dict to OrderedDict if acceptable for you?

BTW, are there any case that keeping the oders of data in a mobi helps to understand the functionality of kindlegen better?


I have made a new patch; but, I do not have any github account. Could you update it on my behalf?

Thanks,

Last edited by KevinH; 10-26-2014 at 12:45 PM.
KevinH is offline   Reply With Quote
Old 10-27-2014, 06:51 AM   #1089
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi Kevin,

Quote:
Originally Posted by KevinH View Post
So I will not integrate an ordered dict patch unless you can explain why it is truly needed. If it is only so you can diff things, then incorporate its use into a DEBUG setting to enable it only when DEBUG is true, otherwise use normal dictionaries.
It is needed only for testing, not for structures of unpacked contents. So, enabling ordered dictionary in DEBUG mode is enough.

Thanks,
tkeo is offline   Reply With Quote
Old 10-30-2014, 06:30 AM   #1090
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: 27,602
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
@tkeo and/or KevinH:

Got an error report over in the plugin thread that I could use more eyes on. I'm not up to speed on all the newer epub3 processing code and this appears to have something to do with a KeyError in the processRefinesMetadata portion of mobi_opf.py.

Thanks.

https://www.mobileread.com/forums/sho...&postcount=281
DiapDealer is online now   Reply With Quote
Old 10-30-2014, 07:56 AM   #1091
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,733
Karma: 5444398
Join Date: Nov 2009
Device: many
Hi DiapDealer,

Yes, this is a bug. It only happens using the Furigana related Exth values that are only generated by Japanese versions of kindlegen. The bug in this case only happens when the book is an epub 2 book, and not an epub 3. I would guess we have never tested this case before ;-).

We should check if the key is in the metadata under epub 2 just like we do when it is an epub3.

Here is the original problem code in mobi_opf.py (starting at line 605)

Code:
        if create_refines_metadata:
            for [EXTH, id, attrib, defaultid] in refines_list:
                if self.target_epubver == '3':
                    for i, value in id.items():
                        attrib[i] = ' id="%s"' % value

                    if EXTH in metadata.keys():
                        if len(metadata[EXTH]) == 1 and len(id) == 1:
                            self.createMetaTag(self.exth_solved_refines_metadata, 'file-as', metadata[EXTH][0], id[0])
                        else:
                            for i, value in enumerate(metadata[EXTH]):
                                self.createMetaTag(self.exth_refines_metadata, 'file-as', value, id.get(i, defaultid))
                else:
                    if len(metadata[EXTH]) == 1 and len(id) == 1:
                        attr = ' opf:file-as="%s"' % metadata[EXTH][0]
                        attrib[0] = attr
                    else:
                        for i, value in enumerate(metadata[EXTH]):
                            attr = ' id="#%s" opf:file-as="%s"\n' % (id.get(i, defaultid), value)
                            self.extra_attributes.append(attr)
It should instead look like the following to at least prevent the KeyError (in other words - to make the else clause mirror the if-then when it comes to Key checking:

Code:
        if create_refines_metadata:
            for [EXTH, id, attrib, defaultid] in refines_list:
                if self.target_epubver == '3':
                    for i, value in id.items():
                        attrib[i] = ' id="%s"' % value

                    if EXTH in metadata.keys():
                        if len(metadata[EXTH]) == 1 and len(id) == 1:
                            self.createMetaTag(self.exth_solved_refines_metadata, 'file-as', metadata[EXTH][0], id[0])
                        else:
                            for i, value in enumerate(metadata[EXTH]):
                                self.createMetaTag(self.exth_refines_metadata, 'file-as', value, id.get(i, defaultid))
                else:
                    if EXTH in metadata.keys():
                        if len(metadata[EXTH]) == 1 and len(id) == 1:
                            attr = ' opf:file-as="%s"' % metadata[EXTH][0]
                            attrib[0] = attr
                        else:
                            for i, value in enumerate(metadata[EXTH]):
                                attr = ' id="#%s" opf:file-as="%s"\n' % (id.get(i, defaultid), value)
                                self.extra_attributes.append(attr)

Please ask the reporter to give that change a try. If it works, I will commit it to the tree and its equivalent to the python2and3 branch as well.

Hope this does the trick.

KevinH
KevinH is offline   Reply With Quote
Old 10-30-2014, 08:11 AM   #1092
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: 27,602
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Thanks Kevin. I'm going to try to get a test version of the plugin (with those changes) to the reporter sometime later today.
DiapDealer is online now   Reply With Quote
Old 10-30-2014, 08:20 AM   #1093
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi Kevin,

Thank you for your quick support.
Yes. It is a bug. I think have made it.


Correction.
Quote:
Originally Posted by KevinH View Post
It only happens using the Furigana related Exth values that are only generated by Japanese versions of kindlegen.
the Furigana related Exth values that are only generated by Japanese versions of KDP.

Thanks,
tkeo is offline   Reply With Quote
Old 10-30-2014, 08:53 AM   #1094
tkeo
Connoisseur
tkeo began at the beginning.
 
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
Hi,

In "auto" mode, an ebook should be converted to epub3 if Furigana relating EXTH exist in it since it requires "refines" attributes.

I will modify mobi_opf.py to do so, after the bug fix is commited.

Thanks,
tkeo is offline   Reply With Quote
Old 10-30-2014, 09:22 AM   #1095
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: 27,602
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Please ask the reporter to give that change a try. If it works, I will commit it to the tree and its equivalent to the python2and3 branch as well.

Hope this does the trick.

KevinH
That indeed, seemed to work for the azw3 the user was having trouble with. Thanks.

Last edited by DiapDealer; 10-30-2014 at 09:24 AM.
DiapDealer is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can i rotate text and insert images in Mobi and EPUB? JanGLi Kindle Formats 5 02-02-2013 04:16 PM
PDF to Mobi with text and images pocketsprocket Kindle Formats 7 05-21-2012 07:06 AM
Mobi files - images DWC Introduce Yourself 5 07-06-2011 01:43 AM
pdf to mobi... creating images rather than text Dumhed Calibre 5 11-06-2010 12:08 PM
Transfer of images on text files anirudh215 PDF 2 06-22-2009 09:28 AM


All times are GMT -4. The time now is 06:24 AM.


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