Code Duplication    Length = 12-12 lines in 2 locations

ocrd/ocrd/processor/base.py 2 locations

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