Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

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