<commit_before># -- XXX This module must not use translation as that causes
# -- a recursive loader import!
from __future__ import absolute_import

from datetime import datetime

from django.conf import settings

# Database-related exceptions.
from django.db import DatabaseError
try:
    import MySQLdb as mysql
    _my_database_errors = (mysql.DatabaseError,
                           mysql.InterfaceError,
                           mysql.OperationalError)
except ImportError:
    _my_database_errors = ()      # noqa
try:
    import psycopg2 as pg
    _pg_database_errors = (pg.DatabaseError,
                           pg.InterfaceError,
                           pg.OperationalError)
except ImportError:
    _pg_database_errors = ()      # noqa
try:
    import sqlite3
    _lite_database_errors = (sqlite3.DatabaseError,
                             sqlite3.InterfaceError,
                             sqlite3.OperationalError)
except ImportError:
    _lite_database_errors = ()    # noqa
try:
    import cx_Oracle as oracle
    _oracle_database_errors = (oracle.DatabaseError,
                               oracle.InterfaceError,
                               oracle.OperationalError)
except ImportError:
    _oracle_database_errors = ()  # noqa

DATABASE_ERRORS = ((DatabaseError, ) +
                   _my_database_errors +
                   _pg_database_errors +
                   _lite_database_errors +
                   _oracle_database_errors)


try:
    from django.utils import timezone
    is_aware = timezone.is_aware

    # see Issue #222
    now_localtime = getattr(timezone, 'template_localtime', timezone.localtime)


    def make_aware(value):
        if getattr(settings, "USE_TZ", False):
            # naive datetimes are assumed to be in UTC.
            value = timezone.make_aware(value, timezone.utc)
            # then convert to the Django configured timezone.
            default_tz = timezone.get_default_timezone()
            value = timezone.localtime(value, default_tz)
        return value

    def make_naive(value):
        if getattr(settings, "USE_TZ", False):
            default_tz = timezone.get_default_timezone()
            value = timezone.make_naive(value, default_tz)
        return value

    def now():
        return now_localtime(timezone.now())

except ImportError:
    now = datetime.now
    make_aware = make_naive = lambda x: x
    is_aware = lambda x : False


def maybe_make_aware(value):
    if isinstance(value, datetime) and is_aware(value):
        return value<commit_msg>Fix now() when USE_TZ is turned off in Django 1.5<commit_after># -- XXX This module must not use translation as that causes
# -- a recursive loader import!
from __future__ import absolute_import

from datetime import datetime

from django.conf import settings

# Database-related exceptions.
from django.db import DatabaseError
try:
    import MySQLdb as mysql
    _my_database_errors = (mysql.DatabaseError,
                           mysql.InterfaceError,
                           mysql.OperationalError)
except ImportError:
    _my_database_errors = ()      # noqa
try:
    import psycopg2 as pg
    _pg_database_errors = (pg.DatabaseError,
                           pg.InterfaceError,
                           pg.OperationalError)
except ImportError:
    _pg_database_errors = ()      # noqa
try:
    import sqlite3
    _lite_database_errors = (sqlite3.DatabaseError,
                             sqlite3.InterfaceError,
                             sqlite3.OperationalError)
except ImportError:
    _lite_database_errors = ()    # noqa
try:
    import cx_Oracle as oracle
    _oracle_database_errors = (oracle.DatabaseError,
                               oracle.InterfaceError,
                               oracle.OperationalError)
except ImportError:
    _oracle_database_errors = ()  # noqa

DATABASE_ERRORS = ((DatabaseError, ) +
                   _my_database_errors +
                   _pg_database_errors +
                   _lite_database_errors +
                   _oracle_database_errors)


try:
    from django.utils import timezone
    is_aware = timezone.is_aware

    # see Issue #222
    now_localtime = getattr(timezone, 'template_localtime', timezone.localtime)


    def make_aware(value):
        if getattr(settings, "USE_TZ", False):
            # naive datetimes are assumed to be in UTC.
            value = timezone.make_aware(value, timezone.utc)
            # then convert to the Django configured timezone.
            default_tz = timezone.get_default_timezone()
            value = timezone.localtime(value, default_tz)
        return value

    def make_naive(value):
        if getattr(settings, "USE_TZ", False):
            default_tz = timezone.get_default_timezone()
            value = timezone.make_naive(value, default_tz)
        return value

    def now():
        if getattr(settings, 'USE_TZ', False):
            return now_localtime(timezone.now())
        else:
            return timezone.now()

except ImportError:
    now = datetime.now
    make_aware = make_naive = lambda x: x
    is_aware = lambda x : False


def maybe_make_aware(value):
    if isinstance(value, datetime) and is_aware(value):
        return value
{'fraction_non_alphanumeric': 0.06690881284649207, 'fraction_numerical': 0.0034410246606767347, 'mean_word_length': 2.1613293051359515, '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': '7273814', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1403, 'n_words': 361}