IndexError: list index out of range

73 views
Skip to first unread message

ArvindKaka

unread,
Jan 27, 2012, 3:14:49 AM1/27/12
to chm2pdf
Hi,
While using the script on a chm file I got the folloing error:

Traceback (most recent call last):
File "/usr/bin/chm2pdf", line 1111, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 1107, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 326, in convert_to_pdf
objective_urls=get_objective_urls_list(filename)
File "/usr/bin/chm2pdf", line 119, in get_objective_urls_list
urls_list.append(spline[5])
IndexError: list index out of range

Would you help me resolve the issue?
Note: I am using the utility in Cygwin.

Reto

unread,
Jan 27, 2012, 3:07:53 PM1/27/12
to chm2pdf
Hi Arvind!

Not shure to be able to help you, but if you provide a little bit more
information I might.
I am not familiar with Cygwin, to use the script I installed a
virtualbox with ubuntu.
You can find the same script but with some bug fixed also here:
https://launchpad.net/ubuntu/+source/chm2pdf
I made also a branch with some more bugs fixed, here:
https://code.launchpad.net/~reto-knaak/chm2pdf/chm2pdf_branch

You could try out if with those versions the same error occours or
not.
Is this error occuring with every chm file or only with a particular
one? Which one?

Or you could add "print 'line',line" 2 lines before File "/usr/bin/
chm2pdf", line 119, in get_objective_urls_list
e.g.:
for line in flist.readlines()[3:]:
#print 'line',line
spline=line.split()
urls_list.append(spline[5])
flist.close()

This will print out the line and then we may have some more clue about
this error you get!
then you can post the result here....
Hope this brings you forward!
Kind regards
Reto

Reto

unread,
Jan 27, 2012, 3:19:27 PM1/27/12
to chm2pdf
Just checked a little more:
In my version of the script, I modified the place which gives you the
error you posted like this:

for line in flist.readlines()[3:]:
#print 'line',line
#This won't work if internal paths of CHM contains spaces:
e.g. /doc space/ will only become /doc
#spline=line.split()
#urls_list.append(spline[5])
#this should work better:
spline= re.sub(r".*?normal file\s*(.*?)\n$", "\\1", line)
if spline[0]=="/":
#print "got spline="+spline
urls_list.append( spline)
flist.close()

Please give some feedback if it works also for you or not!
On need, I can email you the chm2pdf file...

Ciao
Reto

grady...@gmail.com

unread,
May 25, 2013, 9:32:22 PM5/25/13
to chm...@googlegroups.com
This was a tremendous help.  Thank you for sharing.

I have brought this problem and your solution to the attention of developers here (issue #43).
Reply all
Reply to author
Forward
0 new messages