Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

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