Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 04-15-2025, 05:13 PM   #1
mrprobert
Connoisseur
mrprobert began at the beginning.
 
Posts: 60
Karma: 46
Join Date: Mar 2017
Device: None
Embedded Python error after applying 'Rebase OPF Manifest IDs on Current Filenames'

I'm working with an epub that has MathJax scripts. This error is thrown after applying 'Rebase OPF Manifest IDs on Current Filenames':

Code:
Traceback (most recent call last):

  File "C:\Program Files/Sigil/python3lib\fix_opf_ids.py", line 63, in rebase_manifest_ids
    new_id = GetUniqueId(new_id, used_ids)
             ^^^^^^^^^^^

NameError: name 'GetUniqueId' is not defined
Easy work around on my end if I restructure to sigil norm, something I usually prefer not to do.

So, I don't know if this is a bug or not.

Windows 10
Sigil version 2.4.2
Attached Files
File Type: epub GetUniqueId.epub (33.3 KB, 18 views)
mrprobert is offline   Reply With Quote
Old 04-15-2025, 05:34 PM   #2
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,291
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
I am definitely NOT the expert, but it looks like the source has inconsistent path separators...
"C:\Program Files/Sigil/python3lib\fix_opf_ids.py"

I'd bet the restructure automatically fixed all those??
Turtle91 is offline   Reply With Quote
Advert
Old 04-15-2025, 05:36 PM   #3
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 mrprobert View Post
I'm working with an epub that has MathJax scripts. This error is thrown after applying 'Rebase OPF Manifest IDs on Current Filenames':

Code:
Traceback (most recent call last):

  File "C:\Program Files/Sigil/python3lib\fix_opf_ids.py", line 63, in rebase_manifest_ids
    new_id = GetUniqueId(new_id, used_ids)
             ^^^^^^^^^^^

NameError: name 'GetUniqueId' is not defined
Easy work around on my end if I restructure to sigil norm, something I usually prefer not to do.

So, I don't know if this is a bug or not.

Windows 10
Sigil version 2.4.2
Definitely a bug. At a glance, I'd say GetUniqueId needs to be changed to GenerateUniqueId at line 63 of fix_opf_ids.py.

EDIT: The path separators are a red herring in this instance.
DiapDealer is offline   Reply With Quote
Old 04-15-2025, 05:52 PM   #4
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
Making my suggested fix stopped the embedded Python error and allowed the rebase to complete, but I'm not certain the id being generated is ideal.

The epub has two files named 'BasicLatin.js' (in different folders). So after the first file gets the 'BasicLatin_js' id, the second one needs to use something different. But the code is producing 'BasicLatin_jscnt: 0001'.

It's doing what the code asks it to do at that point, but is a colon and a space best practice in an id attribute value?

Asking because I really don't know.
DiapDealer is offline   Reply With Quote
Old 04-15-2025, 07:37 PM   #5
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: 8,434
Karma: 5702578
Join Date: Nov 2009
Device: many
Probably a bug. I will look into it.
KevinH is offline   Reply With Quote
Advert
Old 04-15-2025, 08:14 PM   #6
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: 8,434
Karma: 5702578
Join Date: Nov 2009
Device: many
That bug should now be fixed in master.

Somehow a buggy early version of fix_opf_ids.py got commited to master when my fixed local copy at that time did NOT get committed. Then at some point I force pulled from master and lost that version of the file completely. Luckily I did find a copy on my laptop but either way that code path (duplicate generated ids) was most likely untested.

The results from running that command on supplied testcase ends up as follows:

Code:
<?xml version="1.0" encoding="utf-8"?>
<package version="3.0" unique-identifier="BookId" xml:lang="en" xmlns="http://www.idpf.org/2007/opf">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
    <dc:title>Lorem Ipsum</dc:title>
    <dc:language>en</dc:language>
    <meta property="dcterms:modified">2025-04-15T14:06:23Z</meta>
    <dc:identifier id="BookId">urn:uuid:546f8314-1dd0-457c-8289-1e2c0fcacb57</dc:identifier>
    <meta name="Sigil version" content="2.4.2"/>
  </metadata>
  <manifest>
    <item id="nav_xhtml" href="xhtml/nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
    <item id="section1_xhtml" href="xhtml/section1.xhtml" media-type="application/xhtml+xml"/>
    <item id="BasicLatin_js" href="mathjax/jax/output/SVG/fonts/TeX/Main/Regular/BasicLatin.js" media-type="text/javascript"/>
    <item id="BasicLatin_js0001" href="mathjax/jax/output/SVG/fonts/TeX/Main/Italic/BasicLatin.js" media-type="text/javascript"/>
  </manifest>
  <spine>
    <itemref idref="section1_xhtml"/>
    <itemref idref="nav_xhtml"/>
  </spine>
</package>
If you are on Linux or Windows, I would be happy to post that fixed python script for you to replace its namesake in your version of Sigil.

If you are on MacOS, the full Sigil app is signed and changing any of the code will change the signature potentially causing a problem.

In that case you will have to wait for the next release for the fix.

To workaround this issue, you can just rename the second javascript file temporarily to something unique (filename part not the path), run the tool and then change it back.

Sorry about that.

And thank you for your bug report and nice testcase!

Last edited by KevinH; 04-15-2025 at 08:29 PM.
KevinH is offline   Reply With Quote
Old 04-15-2025, 08:37 PM   #7
mrprobert
Connoisseur
mrprobert began at the beginning.
 
Posts: 60
Karma: 46
Join Date: Mar 2017
Device: None
Thank you for your fix, your attention is much appreciated.
mrprobert is offline   Reply With Quote
Old 04-15-2025, 09:35 PM   #8
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
Interesting. I wasn't aware that Restructure to Sigil Norm would rename duplicate filenames (in different folders) if need be. Makes perfect sense, of course. I was just curious how using it worked around the issue.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Language metadata tag causes embedded python error mrprobert Sigil 4 12-11-2022 03:58 PM
Embedded Python Error on Windows 7 r5dehr9qcs Sigil 11 04-27-2022 06:06 AM
Sigil not fully launching - Embedded Python error BookWalker Sigil 54 01-08-2021 09:08 AM
Embedded Python Error? darkbreath Sigil 13 10-14-2016 07:35 AM
OPF manifest John123 Workshop 7 05-03-2013 06:18 AM


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


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