<commit_before>#
# encoders for various output formats
# 
# the dumps() method will be called
#
import io
import csv
import dicttoxml
from datetime import datetime
import uuid
import {{appname}}
import simplejson as json
import logging
import logging

dicttoxml.LOG.setLevel(logging.ERROR)

def pow_json_serializer(obj):
    """JSON serializer for objects not serializable by default json code"""
    from {{appname}}.models.modelobject import ModelObject
    if isinstance(obj, datetime):
        #serial = obj.isoformat()
        serial = obj.strftime({{appname}}.conf.config.myapp["datetime_format"])
        return serial
    if isinstance(obj, uuid.UUID):
        return str(obj)
    # add your own additions below here.

    if isinstance(obj, ModelObject ):
        try:
            return obj.to_dict()
        except:
            return str(obj)
    try:
        return str(obj)
    except:
        raise TypeError ("Type not serializable" + str(ojb))

class json_to_json:
    """
        receives a list of json and returns a string
    """
    def dumps(self, data):
        try:
            return json.dumps(data, default=pow_json_serializer) 
        except Exception as e:
            raise
        
    

class json_to_csv:
    """ flattens json and converts the flattened<commit_msg>corrected wrong parmater in pow_json_serializer<commit_after>#
# encoders for various output formats
# 
# the dumps() method will be called
#
import io
import csv
import dicttoxml
from datetime import datetime
import uuid
import {{appname}}
import simplejson as json
import logging
import logging

dicttoxml.LOG.setLevel(logging.ERROR)

def pow_json_serializer(obj):
    """JSON serializer for objects not serializable by default json code"""
    from {{appname}}.models.modelobject import ModelObject
    if isinstance(obj, datetime):
        #serial = obj.isoformat()
        serial = obj.strftime({{appname}}.conf.config.myapp["datetime_format"])
        return serial
    if isinstance(obj, uuid.UUID):
        return str(obj)
    # add your own additions below here.

    if isinstance(obj, ModelObject ):
        try:
            return obj.to_dict()
        except:
            return str(obj)
    try:
        return str(obj)
    except:
        raise TypeError ("Type not serializable" + str(obj))

class json_to_json:
    """
        receives a list of json and returns a string
    """
    def dumps(self, data):
        try:
            return json.dumps(data, default=pow_json_serializer) 
        except Exception as e:
            raise
        
    

class json_to_csv:
    """ flattens json and converts the flattened
{'fraction_non_alphanumeric': 0.08428246013667426, 'fraction_numerical': 0.0, 'mean_word_length': 2.727015558698727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5612092', 'n_tokens_mistral': 755, 'n_tokens_neox': 740, 'n_words': 245}