[Checkins] SVN: zopyx.convert2/trunk/src/zopyx/convert2/tidy.py rewrite image references relative to the location of the
Andreas Jung
andreas at andreas-jung.com
Thu Dec 25 03:22:24 EST 2008
Log message for revision 94316:
rewrite image references relative to the location of the
html file to be converted
Changed:
U zopyx.convert2/trunk/src/zopyx/convert2/tidy.py
-=-
Modified: zopyx.convert2/trunk/src/zopyx/convert2/tidy.py
===================================================================
--- zopyx.convert2/trunk/src/zopyx/convert2/tidy.py 2008-12-25 08:12:47 UTC (rev 94315)
+++ zopyx.convert2/trunk/src/zopyx/convert2/tidy.py 2008-12-25 08:22:24 UTC (rev 94316)
@@ -23,7 +23,14 @@
for img in soup.findAll('img'):
src = img['src']
if not os.path.exists(src):
- raise IOError('No image file found: %s' % src)
+ # try to find the image relative to the location of
+ # the HTML file
+ html_dirname = os.path.dirname(filename)
+ possible_img = os.path.join(html_dirname, src)
+ if os.path.exists(possible_img):
+ img['src'] = possible_img
+ else:
+ raise IOError('No image file found: %s' % src)
html = soup.renderContents()
More information about the Checkins
mailing list