<commit_before>#
# Copyright (C) 2011 - 2015 <NAME> <<EMAIL>>
# License: MIT
#
"""A module to aggregate config parser (loader/dumper) backends.
"""
from __future__ import absolute_import

import itertools
import logging
import operator
import pkg_resources

import anyconfig.compat
import anyconfig.utils

import anyconfig.backend.ini
import anyconfig.backend.json
import anyconfig.backend.xml

LOGGER = logging.getLogger(__name__)
PARSERS = [anyconfig.backend.ini.Parser, anyconfig.backend.json.Parser,
           anyconfig.backend.xml.Parser]

try:
    import anyconfig.backend.yaml
    PARSERS.append(anyconfig.backend.yaml.Parser)
except ImportError:
    LOGGER.warn("yaml module is not available. Disabled YAML support.")

try:
    import anyconfig.backend.configobj
    PARSERS.append(anyconfig.backend.configobj.Parser)
except ImportError:
    LOGGER.warn("ConfigObj module is not available. Disabled its support.")

try:
    import anyconfig.backend.msgpack
    PARSERS.append(anyconfig.backend.msgpack.Parser)
except ImportError:
    LOGGER.warn("msgpack module is not available. "
                "Disabled MessagePack support.")

try:
    import anyconfig.backend.toml
    PARSERS.append(anyconfig.backend.toml.Parser)
except ImportError:
    LOGGER.warn("toml module is not available. Disabled TOML support.")

try:
    import anyconfig.backend.bson
    PARSERS.append(anyconfig.backend.bson.Parser)
except ImportError:
    LOGGER.warn("bson module in pymongo package is not available. "
                "Disabled BSON support.")

try:
    import anyconfig.backend.properties
    PARSERS.append(anyconfig.backend.properties.Parser)
except ImportError:
    LOGGER.warn("pyjavaproperties module is not available. Disabled "
                "Java proeperties file support.")

# pylint: disable=no-member
for e in pkg_resources.iter_entry_points("anyconfig_backends"):
    try:
        PARSERS.append(e.load())
    except ImportError:
        continue
# pylint: enable=no-member


def cmp_cps(lhs, rhs):
    """Compare config parsers by these priorities.
    """
    return anyconfig.compat.cmp(lhs.priority(), rhs.priority())


def fst(tpl):
    """
    >>> fst((0, 1))
    0
    """
    return tpl[0]


def snd(tpl):
    """
    >>> snd((0, 1))
    1
    """<commit_msg>enable native Java properties backend by default<commit_after>#
# Copyright (C) 2011 - 2015 <NAME> <<EMAIL>>
# License: MIT
#
"""A module to aggregate config parser (loader/dumper) backends.
"""
from __future__ import absolute_import

import itertools
import logging
import operator
import pkg_resources

import anyconfig.compat
import anyconfig.utils

import anyconfig.backend.ini
import anyconfig.backend.json
import anyconfig.backend.properties
import anyconfig.backend.xml

LOGGER = logging.getLogger(__name__)
PARSERS = [anyconfig.backend.ini.Parser, anyconfig.backend.json.Parser,
           anyconfig.backend.properties.Parser, anyconfig.backend.xml.Parser]

try:
    import anyconfig.backend.yaml
    PARSERS.append(anyconfig.backend.yaml.Parser)
except ImportError:
    LOGGER.warn("yaml module is not available. Disabled YAML support.")

try:
    import anyconfig.backend.configobj
    PARSERS.append(anyconfig.backend.configobj.Parser)
except ImportError:
    LOGGER.warn("ConfigObj module is not available. Disabled its support.")

try:
    import anyconfig.backend.msgpack
    PARSERS.append(anyconfig.backend.msgpack.Parser)
except ImportError:
    LOGGER.warn("msgpack module is not available. "
                "Disabled MessagePack support.")

try:
    import anyconfig.backend.toml
    PARSERS.append(anyconfig.backend.toml.Parser)
except ImportError:
    LOGGER.warn("toml module is not available. Disabled TOML support.")

try:
    import anyconfig.backend.bson
    PARSERS.append(anyconfig.backend.bson.Parser)
except ImportError:
    LOGGER.warn("bson module in pymongo package is not available. "
                "Disabled BSON support.")

# pylint: disable=no-member
for e in pkg_resources.iter_entry_points("anyconfig_backends"):
    try:
        PARSERS.append(e.load())
    except ImportError:
        continue
# pylint: enable=no-member


def cmp_cps(lhs, rhs):
    """Compare config parsers by these priorities.
    """
    return anyconfig.compat.cmp(lhs.priority(), rhs.priority())


def fst(tpl):
    """
    >>> fst((0, 1))
    0
    """
    return tpl[0]


def snd(tpl):
    """
    >>> snd((0, 1))
    1
    """
{'fraction_non_alphanumeric': 0.10596475372797108, 'fraction_numerical': 0.006778129236330773, 'mean_word_length': 3.669831223628692, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2602378', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1363, 'n_words': 335}