Code Duplication    Length = 41-41 lines in 2 locations

pandoc_numbering.py 2 locations

@@ 1349-1389 (lines=41) @@
1346
            )
1347
1348
1349
def meta_entry_space(category, definition, defined):
1350
    """
1351
    Compute entry space for a category.
1352
1353
    Arguments
1354
    ---------
1355
    category
1356
        The category
1357
    definition
1358
        The definition
1359
    defined
1360
        The defined parameter
1361
    """
1362
    if "entry-space" in definition:
1363
        if isinstance(definition["entry-space"], MetaString):
1364
            value = definition["entry-space"].text
1365
        elif (
1366
            isinstance(definition["entry-space"], MetaInlines)
1367
            and len(definition["entry-space"].content) == 1
1368
        ):
1369
            value = definition["entry-space"].content[0].text
1370
        else:
1371
            debug(
1372
                "[WARNING] pandoc-numbering: entry-space is not correct for category "
1373
                + category
1374
            )
1375
            return
1376
        # Get the space
1377
        try:
1378
            space = float(value)
1379
            if space > 0:
1380
                defined[category]["entry-space"] = space
1381
            else:
1382
                debug(
1383
                    "[WARNING] pandoc-numbering: "
1384
                    "entry-space must be positive for category " + category
1385
                )
1386
        except ValueError:
1387
            debug(
1388
                "[WARNING] pandoc-numbering: entry-space is not correct for category "
1389
                + category
1390
            )
1391
1392
@@ 1305-1345 (lines=41) @@
1302
            )
1303
1304
1305
def meta_entry_tab(category, definition, defined):
1306
    """
1307
    Compute entry tab for a category.
1308
1309
    Arguments
1310
    ---------
1311
    category
1312
        The category
1313
    definition
1314
        The definition
1315
    defined
1316
        The defined parameter
1317
    """
1318
    if "entry-tab" in definition:
1319
        if isinstance(definition["entry-tab"], MetaString):
1320
            value = definition["entry-tab"].text
1321
        elif (
1322
            isinstance(definition["entry-tab"], MetaInlines)
1323
            and len(definition["entry-tab"].content) == 1
1324
        ):
1325
            value = definition["entry-tab"].content[0].text
1326
        else:
1327
            debug(
1328
                "[WARNING] pandoc-numbering: entry-tab is not correct for category "
1329
                + category
1330
            )
1331
            return
1332
        # Get the tab
1333
        try:
1334
            tab = float(value)
1335
            if tab > 0:
1336
                defined[category]["entry-tab"] = tab
1337
            else:
1338
                debug(
1339
                    "[WARNING] pandoc-numbering: "
1340
                    "entry-tab must be positive for category " + category
1341
                )
1342
        except ValueError:
1343
            debug(
1344
                "[WARNING] pandoc-numbering: entry-tab is not correct for category "
1345
                + category
1346
            )
1347
1348