<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import sys <EOL> from pants . base . build_environment import pants_release , pants_version <EOL> from pants . help . help_formatter import HelpFormatter <EOL> from pants . help . scope_info_iterator import ScopeInfoIterator <EOL> from pants . option . arg_splitter import ( GLOBAL_SCOPE , NoGoalHelp , OptionsHelp , UnknownGoalHelp , <EOL> VersionHelp ) <EOL> from pants . option . scope import ScopeInfo <EOL> class HelpPrinter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , options ) : <EOL> self . _options = options <EOL> @ property <EOL> def _help_request ( self ) : <EOL> return self . _options . help_request <EOL> def print_help ( self ) : <EOL> """<STR_LIT>""" <EOL> def print_hint ( ) : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> if isinstance ( self . _help_request , VersionHelp ) : <EOL> print ( pants_version ( ) ) <EOL> elif isinstance ( self . _help_request , OptionsHelp ) : <EOL> self . _print_options_help ( ) <EOL> elif isinstance ( self . _help_request , UnknownGoalHelp ) : <EOL> print ( '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( self . _help_request . unknown_goals ) ) ) <EOL> print_hint ( ) <EOL> return <NUM_LIT:1> <EOL> elif isinstance ( self . _help_request , NoGoalHelp ) : <EOL> print ( '<STR_LIT>' ) <EOL> print_hint ( ) <EOL> return <NUM_LIT:1> <EOL> return <NUM_LIT:0> <EOL> def _print_options_help ( self ) : <EOL> """<STR_LIT>""" <EOL> show_all_help = self . _help_request . all_scopes <EOL> if show_all_help : <EOL> help_scopes = self . _options . known_scope_to_info . keys ( ) <EOL> else : <EOL> help_scopes = set ( self . _options . scope_to_flags . keys ( ) ) - set ( [ GLOBAL_SCOPE ] ) <EOL> scope_infos = list ( ScopeInfoIterator ( self . _options . known_scope_to_info ) . iterate ( help_scopes ) ) <EOL> if scope_infos : <EOL> for scope_info in scope_infos : <EOL> help_str = self . _format_help ( scope_info ) <EOL> if help_str : <EOL> print ( help_str ) <EOL> return <EOL> else : <EOL> print ( pants_release ( ) ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( self . _format_help ( ScopeInfo ( GLOBAL_SCOPE , ScopeInfo . GLOBAL ) ) ) <EOL> def _format_help ( self , scope_info ) : <EOL> """<STR_LIT>""" <EOL> scope = scope_info . scope <EOL> description = scope_info . description <EOL> show_recursive = self . _help_request . advanced <EOL> show_advanced = self . _help_request . advanced <EOL> color = sys . stdout . isatty ( ) <EOL> help_formatter = HelpFormatter ( scope , show_recursive , show_advanced , color ) <EOL> return '<STR_LIT:\n>' . join ( help_formatter . format_options ( scope , description , <EOL> self . _options . get_parser ( scope ) . option_registrations_iter ( ) ) ) </s>
