| 
 | |||||||
|  | 
|  | Thread Tools | Search this Thread | 
|  04-15-2025, 05:13 PM | #1 | 
| Connoisseur  Posts: 73 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 definedSo, I don't know if this is a bug or not. Windows 10 Sigil version 2.4.2 | 
|   |   | 
|  04-15-2025, 05:34 PM | #2 | 
| A Hairy Wizard            Posts: 3,395 Karma: 20212733 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?? | 
|   |   | 
| Advert | |
|  | 
|  04-15-2025, 05:36 PM | #3 | |
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | Quote: 
 EDIT: The path separators are a red herring in this instance. | |
|   |   | 
|  04-15-2025, 05:52 PM | #4 | 
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 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.   | 
|   |   | 
|  04-15-2025, 07:37 PM | #5 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			Probably a bug.  I will look into it.
		 | 
|   |   | 
| Advert | |
|  | 
|  04-15-2025, 08:14 PM | #6 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 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 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. | 
|   |   | 
|  04-15-2025, 08:37 PM | #7 | 
| Connoisseur  Posts: 73 Karma: 46 Join Date: Mar 2017 Device: None | 
			
			Thank you for your fix, your attention is much appreciated.
		 | 
|   |   | 
|  04-15-2025, 09:35 PM | #8 | 
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 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.
		 | 
|   |   | 
|  | 
| 
 | 
|  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 |