<commit_before>from __future__ import absolute_import
from django.db.models import IntegerField, PositiveIntegerField
from django.conf import settings

from . import forms
import itertools
from datetime import datetime

from .models import Vote, Score
from .default_settings import RATINGS_VOTES_PER_IP
from .exceptions import *

if 'django.contrib.contenttypes' not in settings.INSTALLED_APPS:
    raise ImportError("djangoratings requires django.contrib.contenttypes in your INSTALLED_APPS")

from django.contrib.contenttypes.models import ContentType

__all__ = ('Rating', 'RatingField', 'AnonymousRatingField')

try:
    from hashlib import md5
except ImportError:
    from md5 import new as md5

try:
    from django.utils.timezone import now
except ImportError:
    now = datetime.now

def md5_hexdigest(value):
    return md5(value).hexdigest()

class Rating(object):
    def __init__(self, score, votes):
        self.score = score
        self.votes = votes

class RatingManager(object):
    def __init__(self, instance, field):
        self.content_type = None
        self.instance = instance
        self.field = field
        
        self.votes_field_name = "%s_votes" % (self.field.name,)
        self.score_field_name = "%s_score" % (self.field.name,)
    <commit_msg>Make md5 sum calculation python2/3 compatible<commit_after>from __future__ import absolute_import
from django.db.models import IntegerField, PositiveIntegerField
from django.conf import settings

from . import forms
import itertools
from datetime import datetime

from .models import Vote, Score
from .default_settings import RATINGS_VOTES_PER_IP
from .exceptions import *

if 'django.contrib.contenttypes' not in settings.INSTALLED_APPS:
    raise ImportError("djangoratings requires django.contrib.contenttypes in your INSTALLED_APPS")

from django.contrib.contenttypes.models import ContentType

__all__ = ('Rating', 'RatingField', 'AnonymousRatingField')

try:
    from hashlib import md5
except ImportError:
    from md5 import new as md5

try:
    from django.utils.timezone import now
except ImportError:
    now = datetime.now

def md5_hexdigest(value):
    return md5(value.encode()).hexdigest()

class Rating(object):
    def __init__(self, score, votes):
        self.score = score
        self.votes = votes

class RatingManager(object):
    def __init__(self, instance, field):
        self.content_type = None
        self.instance = instance
        self.field = field
        
        self.votes_field_name = "%s_votes" % (self.field.name,)
        self.score_field_name = "%s_score" % (self.field.name,)
    
{'fraction_non_alphanumeric': 0.08049060942889996, 'fraction_numerical': 0.004982752012265236, 'mean_word_length': 3.906015037593985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '735299', 'n_tokens_mistral': 780, 'n_tokens_neox': 757, 'n_words': 221}