Merge pull request #11 from eclipseo/fix_for_python3
Convert KindleUnpack/mobiml2xhtml.py to Python 3 syntax
This commit is contained in:
@@ -246,13 +246,13 @@ class MobiMLConverter(object):
|
|||||||
# handle case of end tag with no beginning by injecting empty begin tag
|
# handle case of end tag with no beginning by injecting empty begin tag
|
||||||
taginfo = ('begin', tname, None)
|
taginfo = ('begin', tname, None)
|
||||||
htmlstr += self.processtag(taginfo)
|
htmlstr += self.processtag(taginfo)
|
||||||
print " - fixed by injecting empty start tag ", tname
|
print(" - fixed by injecting empty start tag ", tname)
|
||||||
self.path.append(tname)
|
self.path.append(tname)
|
||||||
elif len(self.path) > 1 and tname == self.path[-2]:
|
elif len(self.path) > 1 and tname == self.path[-2]:
|
||||||
# handle case of dangling missing end
|
# handle case of dangling missing end
|
||||||
taginfo = ('end', self.path[-1], None)
|
taginfo = ('end', self.path[-1], None)
|
||||||
htmlstr += self.processtag(taginfo)
|
htmlstr += self.processtag(taginfo)
|
||||||
print " - fixed by injecting end tag ", self.path[-1]
|
print(" - fixed by injecting end tag ", self.path[-1])
|
||||||
self.path.pop()
|
self.path.pop()
|
||||||
self.path.pop()
|
self.path.pop()
|
||||||
|
|
||||||
@@ -504,18 +504,18 @@ def main(argv=sys.argv):
|
|||||||
infile = argv[1]
|
infile = argv[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print 'Converting Mobi Markup Language to XHTML'
|
print('Converting Mobi Markup Language to XHTML')
|
||||||
mlc = MobiMLConverter(infile)
|
mlc = MobiMLConverter(infile)
|
||||||
print 'Processing ...'
|
print('Processing ...')
|
||||||
htmlstr, css, cssname = mlc.processml()
|
htmlstr, css, cssname = mlc.processml()
|
||||||
outname = infile.rsplit('.',1)[0] + '_converted.html'
|
outname = infile.rsplit('.',1)[0] + '_converted.html'
|
||||||
file(outname, 'wb').write(htmlstr)
|
file(outname, 'wb').write(htmlstr)
|
||||||
file(cssname, 'wb').write(css)
|
file(cssname, 'wb').write(css)
|
||||||
print 'Completed'
|
print('Completed')
|
||||||
print 'XHTML version of book can be found at: ' + outname
|
print('XHTML version of book can be found at: ', outname)
|
||||||
|
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
print "Error: %s" % e
|
print("Error: %s" % e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Reference in New Issue
Block a user