def write(out_fn, fn_idx): xc = XigtCorpus() for fn, igt_indices in fn_idx.items(): # if possible, try to decode needed igts only and skip the rest in_xc = xigtxml.load(fn, mode='transient') # ignoring corpus-level metadata xc.extend(igt for i, igt in enumerate(in_xc) if i in igt_indices) # assume the nsmap of the first igt is the same for all if xc.igts: xc.nsmap = xc[0].nsmap xigtxml.dump(out_fn, xc)