<s> import os , sys , optparse <EOL> from conary . conaryclient import cmdline <EOL> from conary . lib import options <EOL> from conary import versions <EOL> ( NO_PARAM , ONE_PARAM ) = ( options . NO_PARAM , options . ONE_PARAM ) <EOL> ( OPT_PARAM , MULT_PARAM ) = ( options . OPT_PARAM , options . MULT_PARAM ) <EOL> class ConaryCommand ( options . AbstractCommand ) : <EOL> docs = { '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : optparse . SUPPRESS_HELP , <EOL> '<STR_LIT>' : optparse . SUPPRESS_HELP , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> "<STR_LIT>" ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT:root>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( options . VERBOSE_HELP , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> def addParameters ( self , argDef ) : <EOL> d = { } <EOL> d [ '<STR_LIT>' ] = '<STR_LIT:-c>' , MULT_PARAM <EOL> d [ '<STR_LIT>' ] = MULT_PARAM <EOL> d [ '<STR_LIT>' ] = ONE_PARAM <EOL> d [ '<STR_LIT>' ] = MULT_PARAM <EOL> d [ '<STR_LIT>' ] = NO_PARAM <EOL> d [ '<STR_LIT>' ] = NO_PARAM <EOL> d [ '<STR_LIT>' ] = NO_PARAM <EOL> argDef [ self . defaultGroup ] = d <EOL> def addConfigOptions ( self , cfgMap , argDef ) : <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , ONE_PARAM , <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , ONE_PARAM <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , NO_PARAM , <EOL> cfgMap [ '<STR_LIT:root>' ] = '<STR_LIT:root>' , ONE_PARAM , '<STR_LIT>' <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , NO_PARAM <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , NO_PARAM <EOL> cfgMap [ '<STR_LIT>' ] = '<STR_LIT>' , NO_PARAM , <EOL> options . AbstractCommand . addConfigOptions ( self , cfgMap , argDef ) <EOL> def setContext ( self , cfg , argSet ) : <EOL> cmdline . setContext ( cfg , argSet . pop ( '<STR_LIT>' , None ) , <EOL> searchCurrentDir = True ) <EOL> def processConfigOptions ( self , cfg , cfgMap , argSet ) : <EOL> self . setContext ( cfg , argSet ) <EOL> options . AbstractCommand . processConfigOptions ( self , cfg , cfgMap , argSet ) <EOL> l = [ ] <EOL> for labelStr in argSet . get ( '<STR_LIT>' , [ ] ) : <EOL> l . append ( versions . Label ( labelStr ) ) <EOL> if l : <EOL> cfg . installLabelPath = l <EOL> del argSet [ '<STR_LIT>' ] <EOL> for k , v in cfg . environment . items ( ) : <EOL> if v == '<STR_LIT>' : <EOL> cfg . environment . pop ( k ) <EOL> os . environ . pop ( k , None ) <EOL> continue <EOL> os . environ [ k ] = v <EOL> class ConfigCommand ( ConaryCommand ) : <EOL> commands = [ '<STR_LIT>' ] <EOL> help = '<STR_LIT>' <EOL> docs = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> commandGroup = '<STR_LIT>' <EOL> def addParameters ( self , argDef ) : <EOL> ConaryCommand . addParameters ( self , argDef ) <EOL> argDef [ "<STR_LIT>" ] = NO_PARAM <EOL> argDef [ "<STR_LIT>" ] = NO_PARAM <EOL> argDef [ "<STR_LIT>" ] = NO_PARAM <EOL> def runCommand ( self , cfg , argSet , args , ** kwargs ) : <EOL> showPasswords = argSet . pop ( '<STR_LIT>' , False ) <EOL> showContexts = argSet . pop ( '<STR_LIT>' , False ) <EOL> showLineOrigins = argSet . pop ( '<STR_LIT>' , False ) <EOL> try : <EOL> prettyPrint = sys . stdout . isatty ( ) <EOL> except AttributeError : <EOL> prettyPrint = False <EOL> cfg . setDisplayOptions ( hidePasswords = not showPasswords , <EOL> showContexts = showContexts , <EOL> prettyPrint = prettyPrint , <EOL> showLineOrigins = showLineOrigins ) <EOL> if argSet : return self . usage ( ) <EOL> if ( len ( args ) > <NUM_LIT:2> ) : <EOL> return self . usage ( ) <EOL> else : <EOL> cfg . display ( ) <EOL> class HelpCommand ( options . AbstractCommand ) : <EOL> commands = [ '<STR_LIT>' ] <EOL> help = '<STR_LIT>' <EOL> commandGroup = '<STR_LIT>' <EOL> def runCommand ( self , cfg , argSet , args , ** kwargs ) : <EOL> if len ( args ) == <NUM_LIT:3> : <EOL> command = args [ <NUM_LIT:2> ] <EOL> commands = self . mainHandler . _supportedCommands <EOL> if not command in commands : <EOL> print "<STR_LIT>" % ( self . mainHandler . name , <EOL> command ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> commands [ command ] . usage ( ) <EOL> elif len ( args ) == <NUM_LIT:2> : <EOL> self . mainHandler . usage ( showAll = True ) <EOL> return <NUM_LIT:0> <EOL> else : <EOL> print "<STR_LIT>" % ( self . mainHandler . name , <EOL> '<STR_LIT:U+0020>' . join ( args [ <NUM_LIT:2> : ] ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> class MainHandler ( options . MainHandler ) : <EOL> commandList = [ ConfigCommand , HelpCommand ] </s>
