<s> from __future__ import print_function , division , absolute_import <EOL> import json <EOL> import os <EOL> import re <EOL> import sys <EOL> from collections import defaultdict , OrderedDict <EOL> from itertools import chain <EOL> from os import listdir <EOL> from os . path import exists , expanduser , join <EOL> from conda . cli import common <EOL> from conda . compat import iteritems <EOL> help = "<STR_LIT>" <EOL> example = """<STR_LIT>""" <EOL> def configure_parser ( sub_parsers ) : <EOL> p = sub_parsers . add_parser ( <EOL> '<STR_LIT:info>' , <EOL> description = help , <EOL> help = help , <EOL> epilog = example , <EOL> ) <EOL> common . add_parser_json ( p ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = "<STR_LIT:store>" , <EOL> nargs = '<STR_LIT:*>' , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> p . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> p . set_defaults ( func = execute ) <EOL> def show_pkg_info ( name ) : <EOL> from conda . api import get_index <EOL> from conda . resolve import Resolve <EOL> index = get_index ( ) <EOL> r = Resolve ( index ) <EOL> print ( name ) <EOL> if name in r . groups : <EOL> for pkg in sorted ( r . get_pkgs ( name ) ) : <EOL> print ( '<STR_LIT>' % ( <EOL> pkg . version , <EOL> pkg . build , <EOL> common . disp_features ( r . features ( pkg . fn ) ) ) ) <EOL> else : <EOL> print ( '<STR_LIT>' ) <EOL> python_re = re . compile ( '<STR_LIT>' ) <EOL> def get_user_site ( ) : <EOL> site_dirs = [ ] <EOL> if sys . platform != '<STR_LIT:win32>' : <EOL> if exists ( expanduser ( '<STR_LIT>' ) ) : <EOL> for path in listdir ( expanduser ( '<STR_LIT>' ) ) : <EOL> if python_re . match ( path ) : <EOL> site_dirs . append ( "<STR_LIT>" % path ) <EOL> else : <EOL> if '<STR_LIT>' not in os . environ : <EOL> return site_dirs <EOL> APPDATA = os . environ [ '<STR_LIT>' ] <EOL> if exists ( join ( APPDATA , '<STR_LIT>' ) ) : <EOL> site_dirs = [ join ( APPDATA , '<STR_LIT>' , i ) for i in <EOL> listdir ( join ( APPDATA , '<STR_LIT>' ) ) ] <EOL> return site_dirs <EOL> def pretty_package ( pkg ) : <EOL> import conda . config as config <EOL> from conda . utils import human_bytes <EOL> d = OrderedDict ( [ <EOL> ( '<STR_LIT>' , pkg . fn ) , <EOL> ( '<STR_LIT:name>' , pkg . name ) , <EOL> ( '<STR_LIT:version>' , pkg . version ) , <EOL> ( '<STR_LIT>' , pkg . build_number ) , <EOL> ( '<STR_LIT>' , pkg . build ) , <EOL> ( '<STR_LIT>' , config . canonical_channel_name ( pkg . channel ) ) , <EOL> ( '<STR_LIT:size>' , human_bytes ( pkg . info [ '<STR_LIT:size>' ] ) ) , <EOL> ] ) <EOL> rest = pkg . info <EOL> for key in sorted ( rest ) : <EOL> if key in { '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , <EOL> '<STR_LIT:version>' , '<STR_LIT>' , '<STR_LIT:size>' } : <EOL> continue <EOL> d [ key ] = rest [ key ] <EOL> print ( ) <EOL> header = "<STR_LIT>" % ( d [ '<STR_LIT:name>' ] , d [ '<STR_LIT:version>' ] , d [ '<STR_LIT>' ] ) <EOL> print ( header ) <EOL> print ( '<STR_LIT:->' * len ( header ) ) <EOL> for key in d : <EOL> print ( "<STR_LIT>" % ( key , d [ key ] ) ) <EOL> print ( '<STR_LIT>' ) <EOL> for dep in pkg . info [ '<STR_LIT>' ] : <EOL> print ( '<STR_LIT>' % dep ) <EOL> def execute ( args , parser ) : <EOL> import os <EOL> from os . path import dirname <EOL> import conda <EOL> import conda . config as config <EOL> from conda . resolve import Resolve <EOL> from conda . cli . main_init import is_initialized <EOL> from conda . api import get_index , get_package_versions <EOL> if args . root : <EOL> if args . json : <EOL> common . stdout_json ( { '<STR_LIT>' : config . root_dir } ) <EOL> else : <EOL> print ( config . root_dir ) <EOL> return <EOL> if args . packages : <EOL> if args . json : <EOL> results = defaultdict ( list ) <EOL> for arg in args . packages : <EOL> for pkg in get_package_versions ( arg ) : <EOL> results [ arg ] . append ( pkg . _asdict ( ) ) <EOL> common . stdout_json ( results ) <EOL> return <EOL> index = get_index ( ) <EOL> r = Resolve ( index ) <EOL> specs = map ( common . arg2spec , args . packages ) <EOL> for spec in specs : <EOL> versions = r . get_pkgs ( spec ) <EOL> for pkg in sorted ( versions ) : <EOL> pretty_package ( pkg ) <EOL> return <EOL> options = '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> try : <EOL> import requests <EOL> requests_version = requests . __version__ <EOL> except ImportError : <EOL> requests_version = "<STR_LIT>" <EOL> except Exception as e : <EOL> requests_version = "<STR_LIT>" % e <EOL> try : <EOL> import conda_build <EOL> except ImportError : <EOL> conda_build_version = "<STR_LIT>" <EOL> except Exception as e : <EOL> conda_build_version = "<STR_LIT>" % e <EOL> else : <EOL> conda_build_version = conda_build . __version__ <EOL> d = defaultdict ( list ) <EOL> any ( d [ v [ <NUM_LIT:1> ] ] . append ( k ) for k , v in iteritems ( config . get_channel_urls ( ) ) ) <EOL> channels = list ( chain . from_iterable ( d [ q ] for q in sorted ( d , reverse = True ) ) ) <EOL> info_dict = dict ( <EOL> platform = config . subdir , <EOL> conda_version = conda . __version__ , <EOL> conda_build_version = conda_build_version , <EOL> root_prefix = config . root_dir , <EOL> root_writable = config . root_writable , <EOL> pkgs_dirs = config . pkgs_dirs , <EOL> envs_dirs = config . envs_dirs , <EOL> default_prefix = config . default_prefix , <EOL> channels = channels , <EOL> rc_path = config . rc_path , <EOL> user_rc_path = config . user_rc_path , <EOL> sys_rc_path = config . sys_rc_path , <EOL> is_foreign = bool ( config . foreign ) , <EOL> envs = [ ] , <EOL> python_version = '<STR_LIT:.>' . join ( map ( str , sys . version_info ) ) , <EOL> requests_version = requests_version , <EOL> ) <EOL> if args . unsafe_channels : <EOL> if not args . json : <EOL> print ( "<STR_LIT:\n>" . join ( info_dict [ "<STR_LIT>" ] ) ) <EOL> else : <EOL> print ( json . dumps ( { "<STR_LIT>" : info_dict [ "<STR_LIT>" ] } ) ) <EOL> return <NUM_LIT:0> <EOL> else : <EOL> info_dict [ '<STR_LIT>' ] = [ config . hide_binstar_tokens ( c ) for c in <EOL> info_dict [ '<STR_LIT>' ] ] <EOL> if args . all or args . json : <EOL> for option in options : <EOL> setattr ( args , option , True ) <EOL> if args . all or all ( not getattr ( args , opt ) for opt in options ) : <EOL> for key in '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' : <EOL> info_dict [ '<STR_LIT:_>' + key ] = ( '<STR_LIT:\n>' + <NUM_LIT> * '<STR_LIT:U+0020>' ) . join ( info_dict [ key ] ) <EOL> info_dict [ '<STR_LIT>' ] = ( '<STR_LIT>' if info_dict [ '<STR_LIT>' ] else <EOL> '<STR_LIT>' ) <EOL> print ( """<STR_LIT>""" % info_dict ) <EOL> if not is_initialized ( ) : <EOL> print ( """<STR_LIT>""" % config . root_dir ) <EOL> if args . envs : <EOL> common . handle_envs_list ( info_dict [ '<STR_LIT>' ] , not args . json ) <EOL> if args . system and not args . json : <EOL> from conda . cli . find_commands import find_commands , find_executable <EOL> print ( "<STR_LIT>" % ( sys . version [ : <NUM_LIT> ] ) ) <EOL> print ( "<STR_LIT>" % sys . prefix ) <EOL> print ( "<STR_LIT>" % sys . executable ) <EOL> print ( "<STR_LIT>" % dirname ( conda . __file__ ) ) <EOL> for cmd in sorted ( set ( find_commands ( ) + [ '<STR_LIT>' ] ) ) : <EOL> print ( "<STR_LIT>" % ( cmd , find_executable ( '<STR_LIT>' + cmd ) ) ) <EOL> print ( "<STR_LIT>" , end = '<STR_LIT>' ) <EOL> site_dirs = get_user_site ( ) <EOL> if site_dirs : <EOL> print ( site_dirs [ <NUM_LIT:0> ] ) <EOL> else : <EOL> print ( ) <EOL> for site_dir in site_dirs [ <NUM_LIT:1> : ] : <EOL> print ( '<STR_LIT>' % site_dir ) <EOL> print ( ) <EOL> evars = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> if config . platform == '<STR_LIT>' : <EOL> evars . append ( '<STR_LIT>' ) <EOL> elif config . platform == '<STR_LIT>' : <EOL> evars . append ( '<STR_LIT>' ) <EOL> for ev in sorted ( evars ) : <EOL> print ( "<STR_LIT>" % ( ev , os . getenv ( ev , '<STR_LIT>' ) ) ) <EOL> print ( ) <EOL> if args . license and not args . json : <EOL> try : <EOL> from _license import show_info <EOL> show_info ( ) <EOL> except ImportError : <EOL> print ( """<STR_LIT>""" ) <EOL> if args . json : <EOL> common . stdout_json ( info_dict ) </s>
