-#!/bin/env python
+#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# otp_imgswap.py : otp image tag swapper
if match:
tagstr = match.group(0)
path = match.group(1)
- if os.path.isfile(path):
- md5 = get_md5(path)
+ try:
+ if os.path.isfile(path):
+ md5 = get_md5(path)
# tag has alt ?
- slashtag = """<A HREF="/blob.pl?id=%s">""" % (md5,)
- line = line.replace(tagstr, slashtag)
-
+ slashtag = """<A HREF="/blob.pl?id=%s">""" % (md5,)
+ line = line.replace(tagstr, slashtag)
+ except UnicodeEncodeError:
+ print >> sys.stderr, "invalid path: %s (%s)" % (path.encode("utf-8"), line.strip().encode("utf-8"))
print >> out_f, line,