Code Duplication    Length = 12-16 lines in 2 locations

byceps/blueprints/admin/snippet/views.py 1 location

@@ 634-649 (lines=16) @@
631
    return version
632
633
634
def _create_html_diff(
635
    from_version: DbSnippetVersion,
636
    to_version: DbSnippetVersion,
637
    attribute_name: str,
638
) -> Optional[str]:
639
    """Create an HTML diff between the named attribute's value of each
640
    of the two versions.
641
    """
642
    from_description = format_datetime_short(from_version.created_at)
643
    to_description = format_datetime_short(to_version.created_at)
644
645
    from_text = getattr(from_version, attribute_name)
646
    to_text = getattr(to_version, attribute_name)
647
648
    return text_diff_service.create_html_diff(
649
        from_text, to_text, from_description, to_description
650
    )
651
652

byceps/blueprints/admin/news/views.py 1 location

@@ 630-641 (lines=12) @@
627
    return version
628
629
630
def _create_html_diff(from_version, to_version, attribute_name):
631
    """Create an HTML diff between the named attribute's value of each
632
    of the two versions.
633
    """
634
    from_description = format_datetime_short(from_version.created_at)
635
    to_description = format_datetime_short(to_version.created_at)
636
637
    from_text = getattr(from_version, attribute_name)
638
    to_text = getattr(to_version, attribute_name)
639
640
    return text_diff_service.create_html_diff(
641
        from_text, to_text, from_description, to_description
642
    )
643