Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

@@ 299-310 (lines=12) @@
296
                                    file_.pageId, ifg))
297
                    else:
298
                        # filter was inactive but no PAGE is in control, this must not happen
299
                        if on_error == 'skip':
300
                            ift[i] = None
301
                        elif on_error == 'first':
302
                            pass # keep first match
303
                        elif on_error == 'last':
304
                            ift[i] = file_
305
                        elif on_error == 'abort':
306
                            raise ValueError(
307
                                "No PAGE-XML for page '%s' in fileGrp '%s' but multiple matches." % (
308
                                    file_.pageId, ifg))
309
                        else:
310
                            raise Exception("Unknown 'on_error' strategy '%s'" % on_error)
311
                else:
312
                    LOG.debug("adding file %s for page %s to input file group %s", file_.ID, file_.pageId, ifg)
313
                    ift[i] = file_
@@ 277-288 (lines=12) @@
274
                    # fileGrp has multiple files for this page ID
275
                    if mimetype:
276
                        # filter was active, this must not happen
277
                        if on_error == 'skip':
278
                            ift[i] = None
279
                        elif on_error == 'first':
280
                            pass # keep first match
281
                        elif on_error == 'last':
282
                            ift[i] = file_
283
                        elif on_error == 'abort':
284
                            raise ValueError(
285
                                "Multiple '%s' matches for page '%s' in fileGrp '%s'." % (
286
                                    mimetype, file_.pageId, ifg))
287
                        else:
288
                            raise Exception("Unknown 'on_error' strategy '%s'" % on_error)
289
                    elif (ift[i].mimetype == MIMETYPE_PAGE and
290
                          file_.mimetype != MIMETYPE_PAGE):
291
                        pass # keep PAGE match