<commit_before>"""The auto-rebuild system is an optional part of webassets that can be used during development, and can also
be quite convenient on small sites that don't have the performance requirements where a rebuild-check on every
request is fatal.

This module contains classes that help determine whether a rebuild is required for a bundle. This is more
complicated than simply comparing the timestamps of the source and output files.

First, certain filters, in particular CSS compilers like SASS, allow bundle source files to reference
additional files which the user may not have listed in the bundle definition. The bundles support
an additional ``depends`` argument that can list files that should be watched for modification.

Second, if the bundle definition itself changes, i.e., source files being added or removed, or the list of
applied filters modified, the bundle needs to be rebuilt also. Since there is no single fixed place where
bundles are defined, simply watching the timestamp of that bundle definition file is not good enough.

To solve the latter problem, we employ an environment-specific in-memory cache of bundle definition.

"""

import os


__all__ = ('get_updater', 'TimestampUpdater', 'AlwaysUpdater', 'NeverUpdater',)


class BaseUpdater(object):
    """Base updater class.

    Child classes that define an ``id`` attribute are accessible via their
    string id in the configuration.
    """

    class __metaclass__(type):
        UPDATERS = {}

        def __new__(cls, name, bases, attrs):
            new_klass = type.__new__(cls, name, bases, attrs)
            if hasattr(new_klass, 'id'):
                cls.UPDATERS[new_klass.id] = new_klass
            return new_klass

        def get_updater(cls, thing):
            if hasattr(thing, 'needs_rebuild'):
                if isinstance(thing, type):
                    return thing()<commit_msg>Properly wrap this module comment at the invisible right margin.<commit_after>"""The auto-rebuild system is an optional part of webassets that can
be used during development, and can also be quite convenient on small
sites that don't have the performance requirements where a rebuild-check
on every request is fatal.

This module contains classes that help determine whether a rebuild is
required for a bundle. This is more complicated than simply comparing
the timestamps of the source and output files.

First, certain filters, in particular CSS compilers like SASS,
allow bundle source files to reference additional files which the user
may not have listed in the bundle definition. The bundles support an
additional ``depends`` argument that can list files that should be
watched for modification.

Second, if the bundle definition itself changes, i.e., source files
being added or removed, or the list of applied filters modified, the
bundle needs to be rebuilt also. Since there is no single fixed place
where bundles are defined, simply watching the timestamp of that
bundle definition file is not good enough.

To solve the latter problem, we employ an environment-specific
in-memory cache of bundle definition.
"""

import os


__all__ = ('get_updater', 'TimestampUpdater', 'AlwaysUpdater', 'NeverUpdater',)


class BaseUpdater(object):
    """Base updater class.

    Child classes that define an ``id`` attribute are accessible via their
    string id in the configuration.
    """

    class __metaclass__(type):
        UPDATERS = {}

        def __new__(cls, name, bases, attrs):
            new_klass = type.__new__(cls, name, bases, attrs)
            if hasattr(new_klass, 'id'):
                cls.UPDATERS[new_klass.id] = new_klass
            return new_klass

        def get_updater(cls, thing):
            if hasattr(thing, 'needs_rebuild'):
                if isinstance(thing, type):
                    return thing()
{'fraction_non_alphanumeric': 0.06015625, 'fraction_numerical': 0.0, 'mean_word_length': 3.5082159624413145, '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': '5905364', 'n_tokens_mistral': 952, 'n_tokens_neox': 942, 'n_words': 484}