Code Duplication    Length = 31-31 lines in 2 locations

pandoc_numbering/_main.py 2 locations

@@ 1367-1397 (lines=31) @@
1364
                "first-section-level must be positive or zero for category " + category
1365
            )
1366
1367
    if "last-section-level" in definition:
1368
        if isinstance(definition["last-section-level"], MetaString):
1369
            value = definition["last-section-level"].text
1370
        elif (
1371
            isinstance(definition["last-section-level"], MetaInlines)
1372
            and len(definition["last-section-level"].content) == 1
1373
        ):
1374
            value = definition["last-section-level"].content[0].text
1375
        else:
1376
            debug(
1377
                "[WARNING] pandoc-numbering: "
1378
                "last-section-level is not correct for category " + category
1379
            )
1380
            return
1381
1382
        # Get the level
1383
        try:
1384
            level = int(value)
1385
        except ValueError:
1386
            debug(
1387
                "[WARNING] pandoc-numbering: "
1388
                "last-section-level is not correct for category " + category
1389
            )
1390
1391
        if 0 <= level <= 6:
1392
            defined[category]["last-section-level"] = level
1393
        else:
1394
            # pylint: disable=line-too-long
1395
            debug(
1396
                "[WARNING] pandoc-numbering: "
1397
                "last-section-level must be positive or zero for category " + category
1398
            )
1399
1400
@@ 1334-1364 (lines=31) @@
1331
            # Compute the first and last levels section
1332
            defined[category]["first-section-level"] = len(match.group("hidden")) // 2
1333
            defined[category]["last-section-level"] = len(match.group("header")) // 2
1334
    if "first-section-level" in definition:
1335
        if isinstance(definition["first-section-level"], MetaString):
1336
            value = definition["first-section-level"].text
1337
        elif (
1338
            isinstance(definition["first-section-level"], MetaInlines)
1339
            and len(definition["first-section-level"].content) == 1
1340
        ):
1341
            value = definition["first-section-level"].content[0].text
1342
        else:
1343
            debug(
1344
                "[WARNING] pandoc-numbering: "
1345
                "first-section-level is not correct for category " + category
1346
            )
1347
            return
1348
1349
        # Get the level
1350
        try:
1351
            level = int(value) - 1
1352
        except ValueError:
1353
            debug(
1354
                "[WARNING] pandoc-numbering: "
1355
                "first-section-level is not correct for category " + category
1356
            )
1357
1358
        if 0 <= level <= 6:
1359
            defined[category]["first-section-level"] = level
1360
        else:
1361
            # pylint: disable=line-too-long
1362
            debug(
1363
                "[WARNING] pandoc-numbering: "
1364
                "first-section-level must be positive or zero for category " + category
1365
            )
1366
1367
    if "last-section-level" in definition: