<commit_before>from django.core import serializers
from django.core.management.base import CommandError
from django.core.management.base import BaseCommand


class BaseWorkflowCommand(BaseCommand):

    def deserialize_objects(self, fixture, database, verbosity):
        """ Adapted from 'loaddata' django command
            Returns a list of objects loaded from a single fixture;
            no comporession accepted at the moment
        """

        objects_list = []

        humanize = lambda dirname: "'%s'" % dirname if dirname else 'absolute path'
        parts = fixture.split('.')
        if len(parts) == 1:
            fixture_name = parts[0]
            formats = serializers.get_public_serializer_formats()
        else:
            fixture_name, format = '.'.join(parts[:-1]), parts[-1]
            if format in serializers.get_public_serializer_formats():
                formats = [format]
            else:
                formats = []

        if formats:
            if verbosity >= 2:
                self.stdout.write("Checking '%s' fixture..." % fixture_name)
        else:
            raise CommandError(
                "Problem installing fixture '%s': %s is not a known serialization format." %
                    (fixture_name, format))

        fixture_dir = fixture_name

        format = formats[0]
        full_path = '.'.join([fixture_dir, format])

        open_method = open
        try:
            fixture = open_method(full_path, 'r')
        except IOError:
            if verbosity >= 2:
                self.stdout.write("No %s fixture '%s' in %s." % (format, fixture_name, humanize(fixture_dir)))
        else:
            try:
                objects = serializers.deserialize(format, fixture, using=database, ignorenonexistent=False)
                for object in objects:
                    objects_list.append(object)

            except Exception as e:
                if not isinstance(e, CommandError):
                    e.args = ("Problem installing fixture '%s': %s" % (full_path, e),)
                raise<commit_msg>error message fix<commit_after>from django.core import serializers
from django.core.management.base import CommandError
from django.core.management.base import BaseCommand


class BaseWorkflowCommand(BaseCommand):

    def deserialize_objects(self, fixture, database, verbosity):
        """ Adapted from 'loaddata' django command
            Returns a list of objects loaded from a single fixture;
            no comporession accepted at the moment
        """

        objects_list = []

        humanize = lambda dirname: "'%s'" % dirname if dirname else 'absolute path'
        parts = fixture.split('.')
        if len(parts) == 1:
            fixture_name = parts[0]
            formats = serializers.get_public_serializer_formats()
        else:
            fixture_name, format = '.'.join(parts[:-1]), parts[-1]
            if format in serializers.get_public_serializer_formats():
                formats = [format]
            else:
                formats = []

        if formats:
            if verbosity >= 2:
                self.stdout.write("Checking '%s' fixture..." % fixture_name)
        else:
            raise CommandError(
                "Problem deserializing fixture '%s': %s is not a known serialization format." %
                    (fixture_name, format))

        fixture_dir = fixture_name

        format = formats[0]
        full_path = '.'.join([fixture_dir, format])

        open_method = open
        try:
            fixture = open_method(full_path, 'r')
        except IOError:
            if verbosity >= 2:
                self.stdout.write("No %s fixture '%s' in %s." % (format, fixture_name, humanize(fixture_dir)))
        else:
            try:
                objects = serializers.deserialize(format, fixture, using=database, ignorenonexistent=False)
                for object in objects:
                    objects_list.append(object)

            except Exception as e:
                if not isinstance(e, CommandError):
                    e.args = ("Problem deserializing fixture '%s': %s" % (full_path, e),)
                raise
{'fraction_non_alphanumeric': 0.09658817876021143, 'fraction_numerical': 0.003363767419509851, 'mean_word_length': 1.92140350877193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3853708', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1064, 'n_words': 309}