<commit_before>from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from collections import OrderedDict
import importlib
import sys
import six


def watermark():
    """
    Give the version of each of the dependencies -- useful for bug reports.

    Returns
    -------
    result : dict
        mapping the name of each package to its version string or, if an
        optional dependency is not installed, None
    """
    packages = ['six', 'numpy', 'scipy', 'matplotlib', 'pandas', 'pims',
                'pyyaml', 'metadatastore', 'filestore',
                'channelarchiver', 'bubblegum']
    result = OrderedDict()
    for package_name in packages:
        try:
            package = importlib.import_module(package_name)
        except ImportError:
            result[package_name] = None
        else:
            try:
                version = package.__version__
            except AttributeError as err:
                version = "FAILED TO DETECT: {0}".format(err)
        result[package_name] = version

    # enaml provides its version differently
    try:
        import enaml
    except ImportError:
        result['enaml'] = None
    else:
        from enaml.version import version_info
        result['enaml'] = _make_version_string(version_info)

    # ...as does Python
    version_info = sys.version_info
    result['python'] = _make_version_string(version_info)
    return result

def _make_version_string(version_info):
    version_string = '.'.join(map(str, [version_info[0], version_info[1],
                                  version_info[2]]))
    return version_string
<commit_msg>ENN: Make watermark more resilient to err on import.<commit_after>from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from collections import OrderedDict
import importlib
import sys
import six


def watermark():
    """
    Give the version of each of the dependencies -- useful for bug reports.

    Returns
    -------
    result : dict
        mapping the name of each package to its version string or, if an
        optional dependency is not installed, None
    """
    packages = ['six', 'numpy', 'scipy', 'matplotlib', 'pandas', 'pims',
                'pyyaml', 'metadatastore', 'filestore',
                'channelarchiver', 'bubblegum']
    result = OrderedDict()
    for package_name in packages:
        try:
            package = importlib.import_module(package_name)
            version = package.__version__
        except ImportError:
            result[package_name] = None
        except Exception as err:
            version = "FAILED TO DETECT: {0}".format(err)
        result[package_name] = version

    # enaml provides its version differently
    try:
        import enaml
        from enaml.version import version_info
        version = _make_version_string(version_info)
    except ImportError:
        version = None
    except Exception as err:
        version = "FAILED TO DETECT: {0}".format(err)
    result['enaml'] = version

    # ...as does Python
    version_info = sys.version_info
    result['python'] = _make_version_string(version_info)
    return result

def _make_version_string(version_info):
    version_string = '.'.join(map(str, [version_info[0], version_info[1],
                                  version_info[2]]))
    return version_string

{'fraction_non_alphanumeric': 0.08845928529584066, 'fraction_numerical': 0.0026362038664323375, 'mean_word_length': 2.4047856430707877, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4204434', 'n_tokens_mistral': 936, 'n_tokens_neox': 912, 'n_words': 276}