<commit_before>"""Grow static document."""

import os
import re
from grow.common import urls
from grow.routing import path_filter as grow_path_filter


# SHA 256 hash length: 64 characters.
FINGERPRINT_RE = re.compile(
    r'(.*)(-[a-f0-9]{64})(\.min)?([\.][a-z0-9]{1,5})$', re.IGNORECASE)


class Error(Exception):
    """Base static document error."""
    pass


class StaticDocument(object):
    """Static document."""

    def __eq__(self, other):
        return (self.pod == other.pod and self.pod_path == other.pod_path
                and other.locale == self.locale)

    def __init__(self, pod, pod_path, locale=None):
        self.pod = pod
        self.pod_path = pod_path
        self.locale = locale
        self.config = self.pod.router.get_static_config_for_pod_path(pod_path)

        # When localized the base string is changed.
        self._base_path_format = self.config['serve_at']
        self._base_source_path = self.source_path
        self._base_source_path_index = self.source_paths.index(
            self._base_source_path)

        self.use_locale = locale is not None and locale != pod.podspec.default_locale
        if self.use_locale and 'localization' in self.config:
            inherited = {
                'fingerprinted': self.config.get('fingerprinted', False),
            }
            self.config = self.config.get('localization')
            self.config.update(inherited)

        self.use_fallback = 'fallback' not in self.config or self.config['fallback']

    def __ne__(self, other):
        return not self.__eq__(other)

    def __repr__(self):
        if self.locale:
            return "<StaticDocument({}, locale='{}')>".format(
                self.pod_path, self.locale)
        return "<StaticDocument({})>".format(self.pod_path)

    @staticmethod
    def strip_fingerprint(serving_path):
        """Strip the fingerprint off a serving path."""
        return FINGERPRINT_RE.sub(r'\1\3\4', serving_path)

    @property
    def base_path_format(self):
        """Base (non-localized) path format for the static document."""
        return '{}{}'.format(
            self._base_path_format,
            self.sub_base_pod_path)

    @property
    def exists(self):
        """Does the static file exist in the pod?"""
        return self.pod.file_exists(self.source_pod_path)

    @property
    def filter(self):
        """Static configuration filter."""
        return self.config.get('filter', {})

    @property
    def modified(self):
        """File modified timestamp."""
        return self.pod.file_modified(self.pod_path)

    @property
    def size(self):
        """Static file size."""
        return self.pod.file_size(self.pod_path)

    @property
    def fingerprint(self):<commit_msg>Fixing the fingerprint stripping to work without the `.min`.<commit_after>"""Grow static document."""

import os
import re
from grow.common import urls
from grow.routing import path_filter as grow_path_filter


# SHA 256 hash length: 64 characters.
FINGERPRINT_RE = re.compile(
    r'(.*)(-[a-f0-9]{64})((\.min|)[\.][a-z0-9]{1,5})$', re.IGNORECASE)


class Error(Exception):
    """Base static document error."""
    pass


class StaticDocument(object):
    """Static document."""

    def __eq__(self, other):
        return (self.pod == other.pod and self.pod_path == other.pod_path
                and other.locale == self.locale)

    def __init__(self, pod, pod_path, locale=None):
        self.pod = pod
        self.pod_path = pod_path
        self.locale = locale
        self.config = self.pod.router.get_static_config_for_pod_path(pod_path)

        # When localized the base string is changed.
        self._base_path_format = self.config['serve_at']
        self._base_source_path = self.source_path
        self._base_source_path_index = self.source_paths.index(
            self._base_source_path)

        self.use_locale = locale is not None and locale != pod.podspec.default_locale
        if self.use_locale and 'localization' in self.config:
            inherited = {
                'fingerprinted': self.config.get('fingerprinted', False),
            }
            self.config = self.config.get('localization')
            self.config.update(inherited)

        self.use_fallback = 'fallback' not in self.config or self.config['fallback']

    def __ne__(self, other):
        return not self.__eq__(other)

    def __repr__(self):
        if self.locale:
            return "<StaticDocument({}, locale='{}')>".format(
                self.pod_path, self.locale)
        return "<StaticDocument({})>".format(self.pod_path)

    @staticmethod
    def strip_fingerprint(serving_path):
        """Strip the fingerprint off a serving path."""
        return FINGERPRINT_RE.sub(r'\1\3', serving_path)

    @property
    def base_path_format(self):
        """Base (non-localized) path format for the static document."""
        return '{}{}'.format(
            self._base_path_format,
            self.sub_base_pod_path)

    @property
    def exists(self):
        """Does the static file exist in the pod?"""
        return self.pod.file_exists(self.source_pod_path)

    @property
    def filter(self):
        """Static configuration filter."""
        return self.config.get('filter', {})

    @property
    def modified(self):
        """File modified timestamp."""
        return self.pod.file_modified(self.pod_path)

    @property
    def size(self):
        """Static file size."""
        return self.pod.file_size(self.pod_path)

    @property
    def fingerprint(self):
{'fraction_non_alphanumeric': 0.12331233123312331, 'fraction_numerical': 0.005580558055805581, 'mean_word_length': 2.6077922077922078, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7568167', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1620, 'n_words': 387}