Code Duplication    Length = 31-31 lines in 2 locations

pandoc_numbering/_main.py 2 locations

@@ 1425-1455 (lines=31) @@
1422
                "first-section-level must be positive or zero for category " + category
1423
            )
1424
1425
    if "last-section-level" in definition:
1426
        if isinstance(definition["last-section-level"], MetaString):
1427
            value = definition["last-section-level"].text
1428
        elif (
1429
            isinstance(definition["last-section-level"], MetaInlines)
1430
            and len(definition["last-section-level"].content) == 1
1431
        ):
1432
            value = definition["last-section-level"].content[0].text
1433
        else:
1434
            debug(
1435
                "[WARNING] pandoc-numbering: "
1436
                "last-section-level is not correct for category " + category
1437
            )
1438
            return
1439
1440
        # Get the level
1441
        try:
1442
            level = int(value)
1443
        except ValueError:
1444
            debug(
1445
                "[WARNING] pandoc-numbering: "
1446
                "last-section-level is not correct for category " + category
1447
            )
1448
1449
        if 0 <= level <= 6:
1450
            defined[category]["last-section-level"] = level
1451
        else:
1452
            # pylint: disable=line-too-long
1453
            debug(
1454
                "[WARNING] pandoc-numbering: "
1455
                "last-section-level must be positive or zero for category " + category
1456
            )
1457
1458
@@ 1392-1422 (lines=31) @@
1389
            # Compute the first and last levels section
1390
            defined[category]["first-section-level"] = len(match.group("hidden")) // 2
1391
            defined[category]["last-section-level"] = len(match.group("header")) // 2
1392
    if "first-section-level" in definition:
1393
        if isinstance(definition["first-section-level"], MetaString):
1394
            value = definition["first-section-level"].text
1395
        elif (
1396
            isinstance(definition["first-section-level"], MetaInlines)
1397
            and len(definition["first-section-level"].content) == 1
1398
        ):
1399
            value = definition["first-section-level"].content[0].text
1400
        else:
1401
            debug(
1402
                "[WARNING] pandoc-numbering: "
1403
                "first-section-level is not correct for category " + category
1404
            )
1405
            return
1406
1407
        # Get the level
1408
        try:
1409
            level = int(value) - 1
1410
        except ValueError:
1411
            debug(
1412
                "[WARNING] pandoc-numbering: "
1413
                "first-section-level is not correct for category " + category
1414
            )
1415
1416
        if 0 <= level <= 6:
1417
            defined[category]["first-section-level"] = level
1418
        else:
1419
            # pylint: disable=line-too-long
1420
            debug(
1421
                "[WARNING] pandoc-numbering: "
1422
                "first-section-level must be positive or zero for category " + category
1423
            )
1424
1425
    if "last-section-level" in definition: