# Path: checkmate/helpers/hashing.py
# class Hasher(object):
# 
#     def __init__(self):
#         self.digest = hashlib.md5()
# 
#     def add(self,value):
#         if isinstance(value,unicode):
#             v = value.encode("utf-8","ignore")
#         elif isinstance(value,(str)):
#             v = unicode(value,errors = 'replace').encode("utf-8","ignore")
#         elif isinstance(value,(int,float,long,complex,bool)):
#             v = unicode(str(value),errors = 'replace').encode("utf-8","ignore")
#         elif isinstance(value,(tuple,list)):
#             for v in value:
#                 self.add(v)
#             return
#         elif isinstance(value,dict):
#             for key,v in sorted(value.items(),key = lambda x : x[0]):
#                 self.add(key)
#                 self.add(v)
#             return
#         elif value is None:
#             v = '1bcdadabdf0de99dbdb747e951e967c5'
#         else:
#             raise AttributeError("Unhashable type: %s" % str(type(value)))
# 
#         self.digest.update(v)
# 
#     def digest(self):
#         return self.digest


import abc
from checkmate.helpers.hashing import Hasher
                self.ignore[code] = True

    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]


# Path: checkmate/helpers/hashing.py
# class Hasher(object):
# 
#     def __init__(self):
#         self.digest = hashlib.md5()
# 
#     def add(self,value):
#         if isinstance(value,unicode):
#             v = value.encode("utf-8","ignore")
#         elif isinstance(value,(str)):
#             v = unicode(value,errors = 'replace').encode("utf-8","ignore")
#         elif isinstance(value,(int,float,long,complex,bool)):
#             v = unicode(str(value),errors = 'replace').encode("utf-8","ignore")
#         elif isinstance(value,(tuple,list)):
#             for v in value:
#                 self.add(v)
#             return
#         elif isinstance(value,dict):
#             for key,v in sorted(value.items(),key = lambda x : x[0]):
#                 self.add(key)
#                 self.add(v)
#             return
#         elif value is None:
#             v = '1bcdadabdf0de99dbdb747e951e967c5'
#         else:
#             raise AttributeError("Unhashable type: %s" % str(type(value)))
# 
#         self.digest.update(v)
# 
#     def digest(self):
#         return self.digest


# Path: checkmate/lib/analysis/base.py
import abc
from checkmate.helpers.hashing import Hasher

                self.ignore[code] = True

    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()