Repository: kedro-org/kedro
File: kedro/io/data_catalog.py (Python)

Code before:
        )

    @staticmethod
    def _is_pattern(pattern: str):
        """Check if a given string is a pattern. Assume that any name with '{' is a pattern."""
        if "{" in pattern:
            return True
        return False

    @classmethod
    def _match_pattern(
        cls, data_set_patterns: dict[str, dict[str, Any]], data_set_name: str
    ) -> str | None:
        """Match a dataset name against patterns in a dictionary containing patterns"""
        for pattern, _ in data_set_patterns.items():
            result = parse(pattern, data_set_name)
            if result:
                return pattern
        return None

    @classmethod
    def _sort_patterns(
        cls, data_set_patterns: dict[str, dict[str, Any]]
    ) -> dict[str, dict[str, Any]]:
        """Sort a dictionary of dataset patterns according to parsing rules -
        1. Decreasing specificity (no of characters outside the curly brackets
        2. Decreasing number of placeholders (no of curly bracket pairs)
        3. Alphabetically
        """
        sorted_keys = sorted(
            data_set_patterns,
            key=lambda pattern: (
                -(cls._specificity(pattern)),
                -pattern.count("{"),
                pattern,
            ),
        )
        sorted_patterns = {}
        for key in sorted_keys:
            sorted_patterns[key] = data_set_patterns[key]
        return sorted_patterns

    @staticmethod
    def _specificity(pattern: str) -> int:
        """Helper function to check the length of exactly matched characters not inside brackets
        Example -
        specificity("{namespace}.companies") = 10
        specificity("{namespace}.{dataset}") = 1
        specificity("france.companies") = 16
        Args:
            pattern: The factory pattern

Review comment (suggestion):
Nit
```suggestion
        1. Decreasing specificity (number of characters outside the curly brackets)
```

Code after:
                f"are not found in the catalog."
            )

        return cls(
            data_sets=data_sets,
            layers=dataset_layers,
            dataset_patterns=sorted_patterns,
            load_versions=load_versions,
            save_version=save_version,
        )

    @staticmethod
    def _is_pattern(pattern: str):
        """Check if a given string is a pattern. Assume that any name with '{' is a pattern."""
        return "{" in pattern

    @staticmethod
    def _match_pattern(
        data_set_patterns: dict[str, dict[str, Any]], data_set_name: str
    ) -> str | None:
        """Match a dataset name against patterns in a dictionary containing patterns"""
        for pattern, _ in data_set_patterns.items():
            result = parse(pattern, data_set_name)
            if result:
                return pattern
        return None

    @classmethod
    def _sort_patterns(
        cls, data_set_patterns: dict[str, dict[str, Any]]
    ) -> dict[str, dict[str, Any]]:
        """Sort a dictionary of dataset patterns according to parsing rules -
        1. Decreasing specificity (number of characters outside the curly brackets)
        2. Decreasing number of placeholders (number of curly bracket pairs)
        3. Alphabetically
        """
        sorted_keys = sorted(
            data_set_patterns,
            key=lambda pattern: (
                -(cls._specificity(pattern)),
                -pattern.count("{"),
                pattern,
            ),
        )
        sorted_patterns = {}
        for key in sorted_keys:
            sorted_patterns[key] = data_set_patterns[key]
        return sorted_patterns

    @staticmethod
    def _specificity(pattern: str) -> int: