Python utility to split a file by a regexp into parts