<s> from __future__ import print_function , division , absolute_import <EOL> import re <EOL> import os <EOL> import sys <EOL> import subprocess <EOL> from os . path import isdir , isfile , join , expanduser <EOL> from conda . utils import memoized <EOL> def find_executable ( executable , include_others = True ) : <EOL> global dir_paths <EOL> if include_others : <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> dir_paths = [ join ( sys . prefix , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ] <EOL> else : <EOL> dir_paths = [ join ( sys . prefix , '<STR_LIT>' ) ] <EOL> else : <EOL> dir_paths = [ ] <EOL> dir_paths . extend ( os . environ [ '<STR_LIT>' ] . split ( os . pathsep ) ) <EOL> for dir_path in dir_paths : <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> for ext in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> path = join ( dir_path , executable + ext ) <EOL> if isfile ( path ) : <EOL> return path <EOL> else : <EOL> path = join ( dir_path , executable ) <EOL> if isfile ( expanduser ( path ) ) : <EOL> return expanduser ( path ) <EOL> return None <EOL> @ memoized <EOL> def find_commands ( include_others = True ) : <EOL> if include_others : <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> dir_paths = [ join ( sys . prefix , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ] <EOL> else : <EOL> dir_paths = [ join ( sys . prefix , '<STR_LIT>' ) ] <EOL> else : <EOL> dir_paths = [ ] <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> pat = re . compile ( r'<STR_LIT>' ) <EOL> else : <EOL> pat = re . compile ( r'<STR_LIT>' ) <EOL> res = set ( ) <EOL> for dir_path in dir_paths : <EOL> if not isdir ( dir_path ) : <EOL> continue <EOL> for fn in os . listdir ( dir_path ) : <EOL> if not isfile ( join ( dir_path , fn ) ) : <EOL> continue <EOL> m = pat . match ( fn ) <EOL> if m : <EOL> res . add ( m . group ( <NUM_LIT:1> ) ) <EOL> return sorted ( res ) <EOL> def filter_descr ( cmd ) : <EOL> args = [ find_executable ( '<STR_LIT>' + cmd ) , '<STR_LIT>' ] <EOL> if not args [ <NUM_LIT:0> ] : <EOL> print ( '<STR_LIT>' % ( cmd ) ) <EOL> return <EOL> try : <EOL> output = subprocess . check_output ( args ) <EOL> except ( OSError , subprocess . CalledProcessError ) : <EOL> print ( '<STR_LIT>' % ( '<STR_LIT:U+0020>' . join ( args ) ) ) <EOL> return <EOL> pat = re . compile ( r'<STR_LIT>' , re . DOTALL ) <EOL> m = pat . search ( output . decode ( '<STR_LIT:utf-8>' ) ) <EOL> descr = [ '<STR_LIT>' ] if m is None else m . group ( <NUM_LIT:2> ) . splitlines ( ) <EOL> print ( '<STR_LIT>' % ( cmd , descr [ <NUM_LIT:0> ] ) ) <EOL> for d in descr [ <NUM_LIT:1> : ] : <EOL> print ( '<STR_LIT>' % d ) <EOL> def help ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> for cmd in find_commands ( ) : <EOL> filter_descr ( cmd ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> help ( ) </s>
