<commit_before>import logging

from datetime import datetime, timedelta, tzinfo
from time import time, gmtime, strftime

from os.path import dirname

from urlparse import urljoin

from django.conf import settings

from django.db import models
from django.db.models import signals
from django.db.models.fields.files import FieldFile, ImageFieldFile
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.core.files.base import ContentFile
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import simplejson as json
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.sites.models import Site

from django.template.defaultfilters import slugify

try:
    from commons.urlresolvers import reverse
except ImportError, e:
    from django.core.urlresolvers import reverse

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

try:
    from PIL import Image
except ImportError:
    import Image

from .signals import (badge_will_be_awarded, badge_was_awarded)


OBI_VERSION = "0.5.0"

IMG_MAX_SIZE = getattr(settings, "BADGER_IMG_MAX_SIZE", (256, 256))

SITE_ISSUER = getattr(settings, 'BADGER_SITE_ISSUER', {
    "origin": "http://mozilla.org",
    "name": "Badger",
    "org": "Mozilla",
    "contact": "<EMAIL>"
})

DEFAULT_BADGE_IMAGE = getattr(settings, 'BADGER_DEFAULT_BADGE_IMAGE',
    "%s/fixtures/default-badge.png" % dirname(__file__))

# Set up a file system for badge uploads that can be kept separate from the
# rest of /media if necessary. Lots of hackery to ensure sensible defaults.
UPLOADS_ROOT = getattr(settings, 'BADGER_UPLOADS_ROOT',
    '%suploads/' % getattr(settings, 'MEDIA_ROOT', 'media/'))
UPLOADS_URL = getattr(settings, 'BADGER_UPLOADS_URL',
    '%suploads/' % getattr(settings, 'MEDIA_URL', '/media/'))
BADGE_UPLOADS_FS = FileSystemStorage(location=UPLOADS_ROOT,
                                     base_url=UPLOADS_URL)

TIME_ZONE_OFFSET = getattr(settings, "TIME_ZONE_OFFSET", timedelta(0))


class TZOffset(tzinfo):
    """TZOffset"""

    def __init__(self, offset):
        self.offset = offset

    def utcoffset(self, dt):
        return self.offset<commit_msg>Tweaks to how upload paths are built<commit_after>import logging

from datetime import datetime, timedelta, tzinfo
from time import time, gmtime, strftime

import os.path
from os.path import dirname

from urlparse import urljoin

from django.conf import settings

from django.db import models
from django.db.models import signals
from django.db.models.fields.files import FieldFile, ImageFieldFile
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.core.files.base import ContentFile
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import simplejson as json
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.sites.models import Site

from django.template.defaultfilters import slugify

try:
    from commons.urlresolvers import reverse
except ImportError, e:
    from django.core.urlresolvers import reverse

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

try:
    from PIL import Image
except ImportError:
    import Image

from .signals import (badge_will_be_awarded, badge_was_awarded)


OBI_VERSION = "0.5.0"

IMG_MAX_SIZE = getattr(settings, "BADGER_IMG_MAX_SIZE", (256, 256))

SITE_ISSUER = getattr(settings, 'BADGER_SITE_ISSUER', {
    "origin": "http://mozilla.org",
    "name": "Badger",
    "org": "Mozilla",
    "contact": "<EMAIL>"
})

DEFAULT_BADGE_IMAGE = getattr(settings, 'BADGER_DEFAULT_BADGE_IMAGE',
    "%s/fixtures/default-badge.png" % dirname(__file__))

# Set up a file system for badge uploads that can be kept separate from the
# rest of /media if necessary. Lots of hackery to ensure sensible defaults.
UPLOADS_ROOT = getattr(settings, 'BADGER_UPLOADS_ROOT',
    os.path.join(getattr(settings, 'MEDIA_ROOT', 'media/'), 'uploads'))
UPLOADS_URL = getattr(settings, 'BADGER_UPLOADS_URL',
    urljoin(getattr(settings, 'MEDIA_URL', '/media/'), 'uploads/'))
BADGE_UPLOADS_FS = FileSystemStorage(location=UPLOADS_ROOT,
                                     base_url=UPLOADS_URL)

TIME_ZONE_OFFSET = getattr(settings, "TIME_ZONE_OFFSET", timedelta(0))


class TZOffset(tzinfo):
    """TZOffset"""

    def __init__(self, offset):
        self.offset = offset

    def utcoffset(self, dt):
        return self.offset
{'fraction_non_alphanumeric': 0.09082931110136025, 'fraction_numerical': 0.004387889425186486, 'mean_word_length': 4.635352286773795, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5475329', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1433, 'n_words': 397}