(firstPage, secondPage)
This function checks if the provided pages have dynamic content. If they
    are dynamic, proper markings will be made
This function checks if the provided pages have dynamic content. If they
    are dynamic, proper markings will be made
This function checks if the provided pages have dynamic content . If they are dynamic proper markings will be made
def findDynamicContent(firstPage, secondPage):
    """
    This function checks if the provided pages have dynamic content. If they
    are dynamic, proper markings will be made
    """

    if not firstPage or not secondPage:
        return

    infoMsg = "searching for dynamic content"
    logger.info(infoMsg)

    blocks = SequenceMatcher(None, firstPage, secondPage).get_matching_blocks()
    kb.dynamicMarkings = []

    # Removing too small matching blocks
    for block in blocks[:]:
        (_, _, length) = block

        if length <= DYNAMICITY_MARK_LENGTH:
            blocks.remove(block)

    # Making of dynamic markings based on prefix/suffix principle
    if len(blocks) > 0:
        blocks.insert(0, None)
        blocks.append(None)

        for i in xrange(len(blocks) - 1):
            prefix = firstPage[blocks[i][0]:blocks[i][0] + blocks[i][2]] if blocks[i] else None
            suffix = firstPage[blocks[i + 1][0]:blocks[i + 1][0] + blocks[i + 1][2]] if blocks[i + 1] else None

            if prefix is None and blocks[i + 1][0] == 0:
                continue

            if suffix is None and (blocks[i][0] + blocks[i][2] >= len(firstPage)):
                continue

            prefix = trimAlphaNum(prefix)
            suffix = trimAlphaNum(suffix)

            kb.dynamicMarkings.append((prefix[-DYNAMICITY_MARK_LENGTH / 2:] if prefix else None, suffix[:DYNAMICITY_MARK_LENGTH / 2] if suffix else None))

    if len(kb.dynamicMarkings) > 0:
        infoMsg = "dynamic content marked for removal (%d region%s)" % (len(kb.dynamicMarkings), 's' if len(kb.dynamicMarkings) > 1 else '')
        logger.info(infoMsg)
def findDynamicContent ( firstPage , secondPage ) : if not firstPage or not secondPage : return infoMsg = "searching for dynamic content" logger . info ( infoMsg ) blocks = SequenceMatcher ( None , firstPage , secondPage ) . get_matching_blocks ( ) kb . dynamicMarkings = [ ] # Removing too small matching blocks for block in blocks [ : ] : ( _ , _ , length ) = block if length <= DYNAMICITY_MARK_LENGTH : blocks . remove ( block ) # Making of dynamic markings based on prefix/suffix principle if len ( blocks ) > 0 : blocks . insert ( 0 , None ) blocks . append ( None ) for i in xrange ( len ( blocks ) - 1 ) : prefix = firstPage [ blocks [ i ] [ 0 ] : blocks [ i ] [ 0 ] + blocks [ i ] [ 2 ] ] if blocks [ i ] else None suffix = firstPage [ blocks [ i + 1 ] [ 0 ] : blocks [ i + 1 ] [ 0 ] + blocks [ i + 1 ] [ 2 ] ] if blocks [ i + 1 ] else None if prefix is None and blocks [ i + 1 ] [ 0 ] == 0 : continue if suffix is None and ( blocks [ i ] [ 0 ] + blocks [ i ] [ 2 ] >= len ( firstPage ) ) : continue prefix = trimAlphaNum ( prefix ) suffix = trimAlphaNum ( suffix ) kb . dynamicMarkings . append ( ( prefix [ - DYNAMICITY_MARK_LENGTH / 2 : ] if prefix else None , suffix [ : DYNAMICITY_MARK_LENGTH / 2 ] if suffix else None ) ) if len ( kb . dynamicMarkings ) > 0 : infoMsg = "dynamic content marked for removal (%d region%s)" % ( len ( kb . dynamicMarkings ) , 's' if len ( kb . dynamicMarkings ) > 1 else '' ) logger . info ( infoMsg )