Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

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