<s> import collections <EOL> import dcoscli <EOL> import docopt <EOL> from dcos import cmds , config , emitting , http , util <EOL> from dcos . errors import DCOSException <EOL> from dcoscli . subcommand import default_command_info , default_doc <EOL> from dcoscli . util import decorate_docopt_usage <EOL> emitter = emitting . FlatEmitter ( ) <EOL> logger = util . get_logger ( __name__ ) <EOL> def main ( argv ) : <EOL> try : <EOL> return _main ( argv ) <EOL> except DCOSException as e : <EOL> emitter . publish ( e ) <EOL> return <NUM_LIT:1> <EOL> @ decorate_docopt_usage <EOL> def _main ( argv ) : <EOL> args = docopt . docopt ( <EOL> default_doc ( "<STR_LIT>" ) , <EOL> argv = argv , <EOL> version = '<STR_LIT>' . format ( dcoscli . version ) ) <EOL> http . silence_requests_warnings ( ) <EOL> return cmds . execute ( _cmds ( ) , args ) <EOL> def _cmds ( ) : <EOL> """<STR_LIT>""" <EOL> return [ <EOL> cmds . Command ( <EOL> hierarchy = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> arg_keys = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> function = _set ) , <EOL> cmds . Command ( <EOL> hierarchy = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> arg_keys = [ '<STR_LIT>' ] , <EOL> function = _unset ) , <EOL> cmds . Command ( <EOL> hierarchy = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> arg_keys = [ '<STR_LIT>' ] , <EOL> function = _show ) , <EOL> cmds . Command ( <EOL> hierarchy = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> arg_keys = [ ] , <EOL> function = _validate ) , <EOL> cmds . Command ( <EOL> hierarchy = [ '<STR_LIT>' ] , <EOL> arg_keys = [ '<STR_LIT>' ] , <EOL> function = _info ) , <EOL> ] <EOL> def _info ( info ) : <EOL> """<STR_LIT>""" <EOL> emitter . publish ( default_command_info ( "<STR_LIT>" ) ) <EOL> return <NUM_LIT:0> <EOL> def _set ( name , value ) : <EOL> """<STR_LIT>""" <EOL> if name == "<STR_LIT>" : <EOL> notice = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return DCOSException ( notice ) <EOL> if name == "<STR_LIT>" : <EOL> notice = "<STR_LIT>" <EOL> return DCOSException ( notice ) <EOL> config . set_val ( name , value ) <EOL> return <NUM_LIT:0> <EOL> def _unset ( name ) : <EOL> """<STR_LIT>""" <EOL> config . unset ( name ) <EOL> return <NUM_LIT:0> <EOL> def _show ( name ) : <EOL> """<STR_LIT>""" <EOL> toml_config = util . get_config ( True ) <EOL> if name is not None : <EOL> value = toml_config . get ( name ) <EOL> if value is None : <EOL> raise DCOSException ( "<STR_LIT>" . format ( name ) ) <EOL> elif isinstance ( value , collections . Mapping ) : <EOL> raise DCOSException ( config . generate_choice_msg ( name , value ) ) <EOL> else : <EOL> emitter . publish ( value ) <EOL> else : <EOL> for key , value in sorted ( toml_config . property_items ( ) ) : <EOL> if key == "<STR_LIT>" : <EOL> value = "<STR_LIT:*>" * <NUM_LIT:8> <EOL> emitter . publish ( '<STR_LIT>' . format ( key , value ) ) <EOL> return <NUM_LIT:0> <EOL> def _validate ( ) : <EOL> """<STR_LIT>""" <EOL> toml_config = util . get_config ( True ) <EOL> errs = util . validate_json ( toml_config . _dictionary , <EOL> config . generate_root_schema ( toml_config ) ) <EOL> if len ( errs ) != <NUM_LIT:0> : <EOL> emitter . publish ( util . list_to_err ( errs ) ) <EOL> return <NUM_LIT:1> <EOL> emitter . publish ( "<STR_LIT>" ) <EOL> return <NUM_LIT:0> </s>
