<commit_before># -*- coding: UTF-8 -*-
"""
Module for loading/saving data/classes with json
"""

__author__ = "the01"
__email__ = "<EMAIL>"
__copyright__ = "Copyright (C) 2013-15, <NAME>"
__license__ = "MIT"
__version__ = "0.1.5"
__date__ = "2015-12-31"
# Created: 2014-08-29 09:38

import os
import datetime
import json

import dateutil.parser
from dateutil.tz import tzutc

from logable import Logable, ModuleLogable


class Logger(ModuleLogable):
    pass


logger = Logger()
UTC = tzutc()


# TODO: New format according to https://gist.github.com/majgis/4200488
class DateTimeEncoder(json.JSONEncoder):
    """ Encode datetime, date and time objects for json """

    def default(self, obj):
        if isinstance(obj, datetime.datetime):
            # save all without tz info as UTC
            if obj.tzinfo:
                obj = obj.astimezone(UTC).replace(tzinfo=None)
            return {'__datetime__': obj.isoformat() + "Z"}
        elif isinstance(obj, datetime.date):
            return {'__date__': obj.isoformat()}
        elif isinstance(obj, datetime.timedelta):
            # Time delta only stores days, seconds and microseconds
            return {
                '__type__': "timedelta",
                'days': obj.days,
                'seconds': obj.seconds,
                'microseconds': obj.microseconds,<commit_msg>Fix relative import<commit_after># -*- coding: UTF-8 -*-
"""
Module for loading/saving data/classes with json
"""

__author__ = "the01"
__email__ = "<EMAIL>"
__copyright__ = "Copyright (C) 2013-16, <NAME>"
__license__ = "MIT"
__version__ = "0.1.6"
__date__ = "2016-11-25"
# Created: 2014-08-29 09:38

import os
import datetime
import json

import dateutil.parser
from dateutil.tz import tzutc

from .logable import Logable, ModuleLogable


class Logger(ModuleLogable):
    pass


logger = Logger()
UTC = tzutc()


# TODO: New format according to https://gist.github.com/majgis/4200488
class DateTimeEncoder(json.JSONEncoder):
    """ Encode datetime, date and time objects for json """

    def default(self, obj):
        if isinstance(obj, datetime.datetime):
            # save all without tz info as UTC
            if obj.tzinfo:
                obj = obj.astimezone(UTC).replace(tzinfo=None)
            return {'__datetime__': obj.isoformat() + "Z"}
        elif isinstance(obj, datetime.date):
            return {'__date__': obj.isoformat()}
        elif isinstance(obj, datetime.timedelta):
            # Time delta only stores days, seconds and microseconds
            return {
                '__type__': "timedelta",
                'days': obj.days,
                'seconds': obj.seconds,
                'microseconds': obj.microseconds,
{'fraction_non_alphanumeric': 0.1188448722695298, 'fraction_numerical': 0.028878193261754906, 'mean_word_length': 2.6612466124661247, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4076627', 'n_tokens_mistral': 872, 'n_tokens_neox': 797, 'n_words': 229}