<commit_before>#!/usr/bin/env python


### ultra json is really fast
json_is_ujson = True

try:
    import ujson as json
except:
    import json
    json_is_ujson = False

json_dumps = json.dumps

def _dumps(data, sort_keys=False):
    """Handle the fact that ujson.dumps does not
    accept sort_keys as an argument
    """
    if json_is_ujson:
        return json_dumps(data)
    else:
        return json_dumps(data, sort_keys=sort_keys)

json.dumps = _dumps

###
### Exceptions
###

#class InvalidShield(Exception):
class NotAModelException(Exception):    
    """A model has been put together incorrectly
    """
    pass


class NotATypeException(Exception):    
    """A schematics type was not used.
    """<commit_msg>Fix #94, passthrough all args/kwargs to json.dumps<commit_after>#!/usr/bin/env python


import functools
### ultra json is really fast
json_is_ujson = True
try:
    import ujson as json
except ImportError:
    import json
    json_is_ujson = False


@functools.wraps(json.dumps)
def _dumps(*args, **kwargs):
    """Wrapper for ujson.dumps which removes the 'sort_keys' kwarg. Regular
    json.dumps supports sort_keys but ujson.dumps does not.
    """
    kwargs.pop('sort_keys', None)
    return json.dumps(*args, **kwargs)


# Only patch if we are using ujson
if json_is_ujson:
    json.dumps = _dumps


###
### Exceptions
###

#class InvalidShield(Exception):
class NotAModelException(Exception):    
    """A model has been put together incorrectly
    """
    pass


class NotATypeException(Exception):    
    """A schematics type was not used.
    """
{'fraction_non_alphanumeric': 0.1034047919293821, 'fraction_numerical': 0.0012610340479192938, 'mean_word_length': 3.4453781512605044, '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': '4779829', 'n_tokens_mistral': 529, 'n_tokens_neox': 514, 'n_words': 152}