<commit_before># config.py
# Copyright (C) 2008, 2009 <NAME> (<EMAIL>) and contributors
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Module containing module parser implementation able to properly read and write
configuration files"""

import sys
import abc
from functools import wraps
import inspect
from io import BufferedReader, IOBase
import logging
import os
import re
import fnmatch

from git.compat import (
    defenc,
    force_text,
    is_win,
)

from git.util import LockFile

import os.path as osp

import configparser as cp

# typing-------------------------------------------------------

from typing import (Any, Callable, Generic, IO, List, Dict, Sequence,
                    TYPE_CHECKING, Tuple, TypeVar, Union, cast, overload)

from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert_never, _T

if TYPE_CHECKING:
    from git.repo.base import Repo
    from io import BytesIO

T_ConfigParser = TypeVar('T_ConfigParser', bound='GitConfigParser')

if sys.version_info[:3] < (3, 7, 2):
    # typing.Ordereddict not added until py 3.7.2
    from collections import OrderedDict
    OrderedDict_OMD = OrderedDict
elif sys.version_info[:2] >= (3, 10):
    # then deprecated from 3.10 as collections.OrderedDict was made generic
    from collections import OrderedDict
    OrderedDict_OMD = OrderedDict[str, List[_T]]
else:
    from typing import OrderedDict                   # type: ignore  # until 3.6 dropped
    OrderedDict_OMD = OrderedDict[str, List[_T]]  # type: ignore[assignment, misc]

# -------------------------------------------------------------

__all__ = ('GitConfigParser', 'SectionConstraint')


log = logging.getLogger('git.config')
log.addHandler(logging.NullHandler())

# invariants
# represents the configuration level of a configuration file


CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")


# Section pattern to detect conditional includes.
# https://git-scm.com/docs/git-config#_conditional_includes
CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")


class MetaParserBuilder(abc.ABCMeta):
    """Utlity class wrapping base-class methods into decorators that assure read-only properties"""<commit_msg>Rmv py 3.10 check for typing.Ordereddict - its deprecated then, but will still work until 3.12<commit_after># config.py
# Copyright (C) 2008, 2009 <NAME> (<EMAIL>) and contributors
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Module containing module parser implementation able to properly read and write
configuration files"""

import sys
import abc
from functools import wraps
import inspect
from io import BufferedReader, IOBase
import logging
import os
import re
import fnmatch

from git.compat import (
    defenc,
    force_text,
    is_win,
)

from git.util import LockFile

import os.path as osp

import configparser as cp

# typing-------------------------------------------------------

from typing import (Any, Callable, Generic, IO, List, Dict, Sequence,
                    TYPE_CHECKING, Tuple, TypeVar, Union, cast, overload)

from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert_never, _T

if TYPE_CHECKING:
    from git.repo.base import Repo
    from io import BytesIO

T_ConfigParser = TypeVar('T_ConfigParser', bound='GitConfigParser')

if sys.version_info[:3] < (3, 7, 2):
    # typing.Ordereddict not added until py 3.7.2
    from collections import OrderedDict     # type: ignore  # until 3.6 dropped
    OrderedDict_OMD = OrderedDict           # type: ignore  # until 3.6 dropped
else:
    from typing import OrderedDict                   # type: ignore  # until 3.6 dropped
    OrderedDict_OMD = OrderedDict[str, List[_T]]  # type: ignore[assignment, misc]

# -------------------------------------------------------------

__all__ = ('GitConfigParser', 'SectionConstraint')


log = logging.getLogger('git.config')
log.addHandler(logging.NullHandler())

# invariants
# represents the configuration level of a configuration file


CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")


# Section pattern to detect conditional includes.
# https://git-scm.com/docs/git-config#_conditional_includes
CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")


class MetaParserBuilder(abc.ABCMeta):
    """Utlity class wrapping base-class methods into decorators that assure read-only properties"""
{'fraction_non_alphanumeric': 0.14161974880900824, 'fraction_numerical': 0.01104374187960156, 'mean_word_length': 3.399047619047619, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6907432', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1308, 'n_words': 431}