def get_fingerprint_from_code(self,file_revision,location, extra_data=None):
        """
        This function generates a fingerprint from a series of code snippets.

        Can be used by derived analyzers to generate fingerprints based on code
        if nothing better is available.
        """
        code = file_revision.get_file_content()
        if not isinstance(code,unicode):
            code = unicode(code,errors = 'ignore')
        lines = code.split(u"\n")
        s = ""
        for l in location:
            ((from_row,from_column),(to_row,to_column)) = l
            if from_column is None:
                continue
            if from_row == to_row:
                s+=lines[from_row-1][from_column:to_column]
            else:
                if to_row < from_row:
                    raise ValueError("from_row must be smaller than to_row")
                s+=lines[from_row-1][from_column:]
                current_row = from_row+1
                while current_row < to_row:
                    s+=lines[current_row-1]
                    current_row+=1
                s+=lines[current_row-1][:to_column]

        hasher = Hasher()
        hasher.add(s)

        if extra_data is not None:
            hasher.add(extra_data)

        return hasher.digest.hexdigest()
def get_fingerprint_from_code ( self , file_revision , location , extra_data = None ) : code = file_revision . get_file_content ( ) if not isinstance ( code , unicode ) : code = unicode ( code , errors = 'ignore' ) lines = code . split ( u"\n" ) s = "" for l in location : ( ( from_row , from_column ) , ( to_row , to_column ) ) = l if from_column is None : continue if from_row == to_row : s += lines [ from_row - 1 ] [ from_column : to_column ] else : if to_row < from_row : raise ValueError ( "from_row must be smaller than to_row" ) s += lines [ from_row - 1 ] [ from_column : ] current_row = from_row + 1 while current_row < to_row : s += lines [ current_row - 1 ] current_row += 1 s += lines [ current_row - 1 ] [ : to_column ] hasher = Hasher ( ) hasher . add ( s ) if extra_data is not None : hasher . add ( extra_data ) return hasher . digest . hexdigest ( )
This function generates a fingerprint from a series of code snippets.

        Can be used by derived analyzers to generate fingerprints based on code
        if nothing better is available.