Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

@@ 342-353 (lines=12) @@
339
                                file_.pageId, ifg))
340
                    else:
341
                        # filter was inactive but no PAGE is in control, this must not happen
342
                        if on_error == 'skip':
343
                            ift[i] = None
344
                        elif on_error == 'first':
345
                            pass # keep first match
346
                        elif on_error == 'last':
347
                            ift[i] = file_
348
                        elif on_error == 'abort':
349
                            raise ValueError(
350
                                "No PAGE-XML for page '%s' in fileGrp '%s' but multiple matches." % (
351
                                    file_.pageId, ifg))
352
                        else:
353
                            raise Exception("Unknown 'on_error' strategy '%s'" % on_error)
354
                else:
355
                    LOG.debug("adding file %s for page %s to input file group %s", file_.ID, file_.pageId, ifg)
356
                    ift[i] = file_
@@ 320-331 (lines=12) @@
317
                    # fileGrp has multiple files for this page ID
318
                    if mimetype:
319
                        # filter was active, this must not happen
320
                        if on_error == 'skip':
321
                            ift[i] = None
322
                        elif on_error == 'first':
323
                            pass # keep first match
324
                        elif on_error == 'last':
325
                            ift[i] = file_
326
                        elif on_error == 'abort':
327
                            raise ValueError(
328
                                "Multiple '%s' matches for page '%s' in fileGrp '%s'." % (
329
                                    mimetype, file_.pageId, ifg))
330
                        else:
331
                            raise Exception("Unknown 'on_error' strategy '%s'" % on_error)
332
                    elif (ift[i].mimetype == MIMETYPE_PAGE and
333
                          file_.mimetype != MIMETYPE_PAGE):
334
                        pass # keep PAGE match