def replace_dirpath(self, dirpath, stoponerrors=True): |
""" replace temporary links in all html files in dirpath and below """ |
for fpath in dirpath.visit('*.html'): |
html = fpath.read() |
while 1: |
match = self._reg_tempurl.search(html) |
if not match: |
break |
tempurl = match.group(1) |
try: |
html = html.replace('"' + tempurl + '"', |
'"' + self.get_target(tempurl, |
-> fpath.relto(dirpath)) + '"') |
except KeyError: |
if stoponerrors: |
raise |
html = html.replace('"' + tempurl + '"', |
'"apigen.notfound://%s"' % (tempurl,)) |
fpath.write(html) |