<commit_before>from neomodel.exception import InflateError, DeflateError
from datetime import datetime
from datetime import date
import time


def validator(fn):
    if fn.func_name is 'inflate':
        exc_class = InflateError
    elif fn.func_name == 'deflate':
        exc_class = DeflateError
    else:
        raise Exception("Unknown Property method " + fn.func_name)

    def validator(self, value):
        try:
            return fn(self, value)
        except Exception as e:
            raise exc_class(self.name, self.owner, e.message)
    return validator


class Property(object):
    def __init__(self, unique_index=False, index=False, required=False):
        self.required = required
        if unique_index and index:
            raise Exception("unique_index and index are mutually exclusive")
        self.unique_index = unique_index
        self.index = index

    @property
    def is_indexed(self):
        return self.unique_index or self.index


class StringProperty(Property):
    @validator
    def inflate(self, value):
        return unicode(value)

    @validator
    def deflate(self, value):
        return unicode(value)


class IntegerProperty(Property):
    @validator
    def inflate(self, value):
        return int(value)

    @validator
    def deflate(self, value):
        return int(value)


class FloatProperty(Property):
    @validator
    def inflate(self, value):
        return float(value)

    @validator
    def deflate(self, value):
        return float(value)


class BooleanProperty(Property):
    @validator
    def inflate(self, value):
        return bool(value)

    @validator
    def deflate(self, value):
        return bool(value)


class DateProperty(Property):
    @validator
    def inflate(self, value):
        value = unicode(value)
        return datetime.strptime(value, "%Y-%m-%d").date()

    @validator
    def deflate(self, value):
        if not isinstance(value, date):
            raise ValueError(
                'datetime.date object is required, found %s.' % type(value)
                )
        return value.isoformat()


class DatetimeProperty(Property):
    @validator
    # get property from database to obj
    def inflate(self, value):
        if not isinstance(value, (int, long, float)):
            raise ValueError(
                'number is required, found %s.' % type(value)
                )
        return datetime.utcfromtimestamp(value)

    @validator<commit_msg>Fix for inflate with tz<commit_after>from neomodel.exception import InflateError, DeflateError
from datetime import datetime
from datetime import date
import time
import pytz


def validator(fn):
    if fn.func_name is 'inflate':
        exc_class = InflateError
    elif fn.func_name == 'deflate':
        exc_class = DeflateError
    else:
        raise Exception("Unknown Property method " + fn.func_name)

    def validator(self, value):
        try:
            return fn(self, value)
        except Exception as e:
            raise exc_class(self.name, self.owner, e.message)
    return validator


class Property(object):
    def __init__(self, unique_index=False, index=False, required=False):
        self.required = required
        if unique_index and index:
            raise Exception("unique_index and index are mutually exclusive")
        self.unique_index = unique_index
        self.index = index

    @property
    def is_indexed(self):
        return self.unique_index or self.index


class StringProperty(Property):
    @validator
    def inflate(self, value):
        return unicode(value)

    @validator
    def deflate(self, value):
        return unicode(value)


class IntegerProperty(Property):
    @validator
    def inflate(self, value):
        return int(value)

    @validator
    def deflate(self, value):
        return int(value)


class FloatProperty(Property):
    @validator
    def inflate(self, value):
        return float(value)

    @validator
    def deflate(self, value):
        return float(value)


class BooleanProperty(Property):
    @validator
    def inflate(self, value):
        return bool(value)

    @validator
    def deflate(self, value):
        return bool(value)


class DateProperty(Property):
    @validator
    def inflate(self, value):
        value = unicode(value)
        return datetime.strptime(value, "%Y-%m-%d").date()

    @validator
    def deflate(self, value):
        if not isinstance(value, date):
            raise ValueError(
                'datetime.date object is required, found %s.' % type(value)
                )
        return value.isoformat()


class DatetimeProperty(Property):
    @validator
    # get property from database to obj
    def inflate(self, value):
        if not isinstance(value, (int, long, float)):
            raise ValueError(
                'number is required, found %s.' % type(value)
                )
        return datetime.utcfromtimestamp(value).replace(tzinfo=pytz.utc)

    @validator
{'fraction_non_alphanumeric': 0.08908103760305651, 'fraction_numerical': 0.0, 'mean_word_length': 2.535181236673774, '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': '4516418', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1374, 'n_words': 399}