<commit_before>from __future__ import unicode_literals

import functools
import os
import platform
import sys

import pygst
pygst.require('0.10')
import gst

import pkg_resources

from . import formatting


def list_deps_optparse_callback(*args):
    """
    Prints a list of all dependencies.

    Called by optparse when Mopidy is run with the :option:`--list-deps`
    option.
    """
    print format_dependency_list()
    sys.exit(0)


def format_dependency_list(adapters=None):
    if adapters is None:
        adapters = [
            platform_info,
            python_info,
            gstreamer_info,
            functools.partial(pkg_info, 'Mopidy', True),
        ]

        dist_names = set([
            ep.dist.project_name for ep in
            pkg_resources.iter_entry_points('mopidy.ext')
            if ep.dist.project_name != 'Mopidy'])
        for dist_name in dist_names:
            adapters.append(
                functools.partial(pkg_info, dist_name))

    return '\n'.join([_format_dependency(a()) for a in adapters])


def _format_dependency(dep_info):
    lines = []

    if 'version' not in dep_info:
        lines.append('%s: not found' % dep_info['name'])
    else:
        lines.append('%s: %s from %s' % (<commit_msg>deps: Move GStreamer to the bottom<commit_after>from __future__ import unicode_literals

import functools
import os
import platform
import sys

import pygst
pygst.require('0.10')
import gst

import pkg_resources

from . import formatting


def list_deps_optparse_callback(*args):
    """
    Prints a list of all dependencies.

    Called by optparse when Mopidy is run with the :option:`--list-deps`
    option.
    """
    print format_dependency_list()
    sys.exit(0)


def format_dependency_list(adapters=None):
    if adapters is None:
        dist_names = set([
            ep.dist.project_name for ep in
            pkg_resources.iter_entry_points('mopidy.ext')
            if ep.dist.project_name != 'Mopidy'])
        dist_infos = [
            functools.partial(pkg_info, dist_name)
            for dist_name in dist_names]

        adapters = [
            platform_info,
            python_info,
            functools.partial(pkg_info, 'Mopidy', True)
        ] + dist_infos + [
            gstreamer_info,
        ]

    return '\n'.join([_format_dependency(a()) for a in adapters])


def _format_dependency(dep_info):
    lines = []

    if 'version' not in dep_info:
        lines.append('%s: not found' % dep_info['name'])
    else:
        lines.append('%s: %s from %s' % (
{'fraction_non_alphanumeric': 0.0987411487018096, 'fraction_numerical': 0.003147128245476003, 'mean_word_length': 2.5221606648199444, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3701424', 'n_tokens_mistral': 841, 'n_tokens_neox': 797, 'n_words': 200}