def remove_blank(hklin, hklout): '''Find and remove blank batches from the file. Returns hklin if no blanks.''' blanks, goods = find_blank(hklin) if not blanks: return hklin # if mostly blank return hklin too... if len(blanks) > len(goods): Debug.write('%d blank vs. %d good: ignore' % (len(blanks), len(goods))) return hklin rb = Rebatch() rb.set_hklin(hklin) rb.set_hklout(hklout) for b in blanks: rb.exclude_batch(b) rb.exclude_batches() return hklout