<s> from __future__ import absolute_import , unicode_literals <EOL> import functools <EOL> import os <EOL> import platform <EOL> import sys <EOL> import pkg_resources <EOL> from mopidy . internal import formatting <EOL> from mopidy . internal . gi import Gst , gi <EOL> def format_dependency_list ( adapters = None ) : <EOL> if adapters is None : <EOL> dist_names = set ( [ <EOL> ep . dist . project_name for ep in <EOL> pkg_resources . iter_entry_points ( '<STR_LIT>' ) <EOL> if ep . dist . project_name != '<STR_LIT>' ] ) <EOL> dist_infos = [ <EOL> functools . partial ( pkg_info , dist_name ) <EOL> for dist_name in dist_names ] <EOL> adapters = [ <EOL> executable_info , <EOL> platform_info , <EOL> python_info , <EOL> functools . partial ( pkg_info , '<STR_LIT>' , True ) <EOL> ] + dist_infos + [ <EOL> gstreamer_info , <EOL> ] <EOL> return '<STR_LIT:\n>' . join ( [ _format_dependency ( a ( ) ) for a in adapters ] ) <EOL> def _format_dependency ( dep_info ) : <EOL> lines = [ ] <EOL> if '<STR_LIT:version>' not in dep_info : <EOL> lines . append ( '<STR_LIT>' % dep_info [ '<STR_LIT:name>' ] ) <EOL> else : <EOL> if '<STR_LIT:path>' in dep_info : <EOL> source = '<STR_LIT>' % dep_info [ '<STR_LIT:path>' ] <EOL> else : <EOL> source = '<STR_LIT>' <EOL> lines . append ( '<STR_LIT>' % ( <EOL> dep_info [ '<STR_LIT:name>' ] , <EOL> dep_info [ '<STR_LIT:version>' ] , <EOL> source , <EOL> ) ) <EOL> if '<STR_LIT>' in dep_info : <EOL> lines . append ( '<STR_LIT>' % ( <EOL> formatting . indent ( dep_info [ '<STR_LIT>' ] , places = <NUM_LIT:4> ) ) , ) <EOL> if dep_info . get ( '<STR_LIT>' , [ ] ) : <EOL> for sub_dep_info in dep_info [ '<STR_LIT>' ] : <EOL> sub_dep_lines = _format_dependency ( sub_dep_info ) <EOL> lines . append ( <EOL> formatting . indent ( sub_dep_lines , places = <NUM_LIT:2> , singles = True ) ) <EOL> return '<STR_LIT:\n>' . join ( lines ) <EOL> def executable_info ( ) : <EOL> return { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : sys . argv [ <NUM_LIT:0> ] , <EOL> } <EOL> def platform_info ( ) : <EOL> return { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : platform . platform ( ) , <EOL> } <EOL> def python_info ( ) : <EOL> return { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT>' % ( <EOL> platform . python_implementation ( ) , platform . python_version ( ) ) , <EOL> '<STR_LIT:path>' : os . path . dirname ( platform . __file__ ) , <EOL> } <EOL> def pkg_info ( project_name = None , include_extras = False ) : <EOL> if project_name is None : <EOL> project_name = '<STR_LIT>' <EOL> try : <EOL> distribution = pkg_resources . get_distribution ( project_name ) <EOL> extras = include_extras and distribution . extras or [ ] <EOL> dependencies = [ <EOL> pkg_info ( d ) for d in distribution . requires ( extras ) ] <EOL> return { <EOL> '<STR_LIT:name>' : project_name , <EOL> '<STR_LIT:version>' : distribution . version , <EOL> '<STR_LIT:path>' : distribution . location , <EOL> '<STR_LIT>' : dependencies , <EOL> } <EOL> except pkg_resources . ResolutionError : <EOL> return { <EOL> '<STR_LIT:name>' : project_name , <EOL> } <EOL> def gstreamer_info ( ) : <EOL> other = [ ] <EOL> other . append ( '<STR_LIT>' % gi . __version__ ) <EOL> found_elements = [ ] <EOL> missing_elements = [ ] <EOL> for name , status in _gstreamer_check_elements ( ) : <EOL> if status : <EOL> found_elements . append ( name ) <EOL> else : <EOL> missing_elements . append ( name ) <EOL> other . append ( '<STR_LIT>' ) <EOL> other . append ( '<STR_LIT>' ) <EOL> for element in found_elements : <EOL> other . append ( '<STR_LIT>' % element ) <EOL> if not found_elements : <EOL> other . append ( '<STR_LIT>' ) <EOL> other . append ( '<STR_LIT>' ) <EOL> for element in missing_elements : <EOL> other . append ( '<STR_LIT>' % element ) <EOL> if not missing_elements : <EOL> other . append ( '<STR_LIT>' ) <EOL> return { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT:.>' . join ( map ( str , Gst . version ( ) ) ) , <EOL> '<STR_LIT:path>' : os . path . dirname ( gi . __file__ ) , <EOL> '<STR_LIT>' : '<STR_LIT:\n>' . join ( other ) , <EOL> } <EOL> def _gstreamer_check_elements ( ) : <EOL> elements_to_check = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> known_elements = [ <EOL> factory . get_name ( ) for factory in <EOL> Gst . Registry . get ( ) . get_feature_list ( Gst . ElementFactory ) ] <EOL> return [ <EOL> ( element , element in known_elements ) for element in elements_to_check ] </s>
