In my testing I added print statements to track calibre's progress through this function, but could never get inside or beyond this loop.  Print statements before the loop appear as expected, but ones inside or after the loop never show up.  If I take the re.finditer call out of the for statement and give it its own line (e.g. test = re.finditer(...)) then that's the line that I can't get past, so something must be wrong with that statement.  However, no error is being raised so I'm not sure what's going on beyond the fact that no code after the re.finditer call is executed.  I'll try to get back to this and play with it more later to see if I can figure out something more helpful.