<commit_before>"""
TZ helper functions backported from Django 1.4. This module should only 
get loaded if django.utils.timezone doesn't exist.
"""


try:
    import pytz
except ImportError:
    pytz = None


__all__ = [
    'utc', 'is_aware'
]

# UTC and local time zones

ZERO = timedelta(0)

class UTC(tzinfo):
    """
    UTC implementation taken from Python's docs.

    Used only when pytz isn't available.
    """

    def __repr__(self):
        return "<UTC>"

    def utcoffset(self, dt):
        return ZERO

    def tzname(self, dt):
        return "UTC"

    def dst(self, dt):
        return ZERO

utc = pytz.utc if pytz else UTC()
"""UTC time zone as a tzinfo instance."""


def is_aware(value):
    """
    Determines if a given datetime.datetime is aware.

    The logic is described in Python's docs:
    http://docs.python.org/library/datetime.html#datetime.tzinfo
    """
    return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None
<commit_msg>Add missing timedelta import for timezone backport<commit_after>"""
TZ helper functions backported from Django 1.4. This module should only 
get loaded if django.utils.timezone doesn't exist.
"""
from datetime import timedelta

try:
    import pytz
except ImportError:
    pytz = None


__all__ = [
    'utc', 'is_aware'
]

# UTC and local time zones

ZERO = timedelta(0)

class UTC(tzinfo):
    """
    UTC implementation taken from Python's docs.

    Used only when pytz isn't available.
    """

    def __repr__(self):
        return "<UTC>"

    def utcoffset(self, dt):
        return ZERO

    def tzname(self, dt):
        return "UTC"

    def dst(self, dt):
        return ZERO

utc = pytz.utc if pytz else UTC()
"""UTC time zone as a tzinfo instance."""


def is_aware(value):
    """
    Determines if a given datetime.datetime is aware.

    The logic is described in Python's docs:
    http://docs.python.org/library/datetime.html#datetime.tzinfo
    """
    return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None

{'fraction_non_alphanumeric': 0.09630668536699392, 'fraction_numerical': 0.002805049088359046, 'mean_word_length': 2.3968253968253967, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4089255', 'n_tokens_mistral': 755, 'n_tokens_neox': 657, 'n_words': 226}