<commit_before>from BeautifulSoup import BeautifulSoup
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from sekizai.filters.base import BaseFilter
from subprocess import Popen, PIPE

class Minifier(object):
    """
    A class wrapping a command line tool to minify data
    """
    def __init__(self, command):
        self.command = command.split(' ')
        
    def __call__(self, data):
        """
        Call the command with given data and return the output of the command if
        successful. Otherwise return the input data.
        """
        process = Popen(self.command, stdout=PIPE, stdin=PIPE, stderr=PIPE)
        stdout = process.communicate(data)[0]
        if process.returncode != 0: # pragma: no cover 
            return data
        return stdout
    
    
class NullMinifier(object):
    """
    Dummy minifier class.
    """<commit_msg>added a warning to failing minificaiton<commit_after>from BeautifulSoup import BeautifulSoup
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from sekizai.filters.base import BaseFilter
from subprocess import Popen, PIPE
import warnings


class MinifierWarning(Warning):
    """
    Warning which gets raised if the minifier subprocess fails.
    """


class Minifier(object):
    """
    A class wrapping a command line tool to minify data
    """
    def __init__(self, command):
        self.command = command.split(' ')
        
    def __call__(self, data):
        """
        Call the command with given data and return the output of the command if
        successful. Otherwise return the input data.
        """
        process = Popen(self.command, stdout=PIPE, stdin=PIPE, stderr=PIPE)
        stdout, stderr = process.communicate(data)
        if process.returncode != 0: # pragma: no cover
            warnings.warn(
                "Could not minify '%s' using '%s', subprocess failed with "
                "'%s'." % (data, ' '.join(self.command), stderr),
                MinifierWarning) 
            return data
        return stdout
    
    
class NullMinifier(object):
    """
    Dummy minifier class.
    """
{'fraction_non_alphanumeric': 0.08494031221303948, 'fraction_numerical': 0.0013774104683195593, 'mean_word_length': 2.5838815789473686, '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': '1538381', 'n_tokens_mistral': 599, 'n_tokens_neox': 586, 'n_words': 200}