Qc@sdZddkZddkZddkZddkZddkZddkZddkZyddkZWne j o e ZnXyddk Z Wne j o e Z nXddk Z dei jZdZdZdZdefdYZd efd YZd efd YZd efdYZdefdYZdefdYZdefdYZdefdYZhadZdZdZe de ddZdZ dZ!dZ"d fd!YZ#e#Z$d"Z%d#Z&d$Z'd%fd&YZ(d'e)fd(YZ*d)e+fd*YZ,d+fd,YZ-d-e-fd.YZ.d/e$d0Z/e$d1Z0d2Z1e$e d3Z2e$d4Z3e$e d5Z4e$d6Z5e$d7Z6e$d8Z7d9e,fd:YZ8d;e(fd<YZ9e$d=Z:e:Z;d>e9fd?YZ<d@e9fdAYZ=dBe9fdCYZ>dDe,fdEYZ?dFe?fdGYZ@e e e$dHZAdIe?fdJYZBe e e$dKZCdLe,fdMYZDdNe(fdOYZEe$dPZFdQe,fdRYZGdSeGfdTYZHdUeGfdVYZIe$dWZJe$dXZKdYe(fdZYZLe$d[ZMe$d\ZNe e e$d]ZOe e e$d^ZPe3e<e3e>e3e=e#ZQe7d_dd`eQe7daddbeQdS(cs5This module is used to define and parse command line flags. This module defines a *distributed* flag-definition policy: rather than an application having to define all flags in or near main(), each python module defines flags that are useful to it. When one python module imports another, it gains access to the other's flags. (This is implemented by having all modules share a common, global registry object containing all the flag information.) Flags are defined through the use of one of the DEFINE_xxx functions. The specific function used determines how the flag is parsed, checked, and optionally type-converted, when it's seen on the command line. IMPLEMENTATION: DEFINE_* creates a 'Flag' object and registers it with a 'FlagValues' object (typically the global FlagValues FLAGS, defined here). The 'FlagValues' object can scan the command line arguments and pass flag arguments to the corresponding 'Flag' objects for value-checking and type conversion. The converted flag values are available as attributes of the 'FlagValues' object. Code can access the flag through a FlagValues object, for instance gflags.FLAGS.myflag. Typically, the __main__ module passes the command line arguments to gflags.FLAGS for parsing. At bottom, this module calls getopt(), so getopt functionality is supported, including short- and long-style flags, and the use of -- to terminate flags. Methods defined by the flag module will throw 'FlagsError' exceptions. The exception argument will be a human-readable string. FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags take a name, default value, help-string, and optional 'short' name (one-letter name). Some flags have other arguments, which are described with the flag. DEFINE_string: takes any input, and interprets it as a string. DEFINE_bool or DEFINE_boolean: typically does not take an argument: say --myflag to set FLAGS.myflag to true, or --nomyflag to set FLAGS.myflag to false. Alternately, you can say --myflag=true or --myflag=t or --myflag=1 or --myflag=false or --myflag=f or --myflag=0 DEFINE_float: takes an input and interprets it as a floating point number. Takes optional args lower_bound and upper_bound; if the number specified on the command line is out of range, it will raise a FlagError. DEFINE_integer: takes an input and interprets it as an integer. Takes optional args lower_bound and upper_bound as for floats. DEFINE_enum: takes a list of strings which represents legal values. If the command-line value is not in this list, raise a flag error. Otherwise, assign to FLAGS.flag as a string. DEFINE_list: Takes a comma-separated list of strings on the commandline. Stores them in a python list object. DEFINE_spaceseplist: Takes a space-separated list of strings on the commandline. Stores them in a python list object. Example: --myspacesepflag "foo bar baz" DEFINE_multistring: The same as DEFINE_string, except the flag can be specified more than once on the commandline. The result is a python list object (list of strings), even if the flag is only on the command line once. DEFINE_multi_int: The same as DEFINE_integer, except the flag can be specified more than once on the commandline. The result is a python list object (list of ints), even if the flag is only on the command line once. SPECIAL FLAGS: There are a few flags that have special meaning: --help prints a list of all the flags in a human-readable fashion --helpshort prints a list of all key flags (see below). --helpxml prints a list of all flags, in XML format. DO NOT parse the output of --help and --helpshort. Instead, parse the output of --helpxml. For more info, see "OUTPUT FOR --helpxml" below. --flagfile=foo read flags from file foo. --undefok=f1,f2 ignore unrecognized option errors for f1,f2. For boolean flags, you should use --undefok=boolflag, and --boolflag and --noboolflag will be accepted. Do not use --undefok=noboolflag. -- as in getopt(), terminates flag-processing FLAGS VALIDATORS: If your program: - requires flag X to be specified - needs flag Y to match a regular expression - or requires any more general constraint to be satisfied then validators are for you! Each validator represents a constraint over one flag, which is enforced starting from the initial parsing of the flags and until the program terminates. Also, lower_bound and upper_bound for numerical flags are enforced using flag validators. Howto: If you want to enforce a constraint over one flag, use gflags.RegisterValidator(flag_name, checker, message='Flag validation failed', flag_values=FLAGS) After flag values are initially parsed, and after any change to the specified flag, method checker(flag_value) will be executed. If constraint is not satisfied, an IllegalFlagValue exception will be raised. See RegisterValidator's docstring for a detailed explanation on how to construct your own checker. EXAMPLE USAGE: FLAGS = gflags.FLAGS gflags.DEFINE_integer('my_version', 0, 'Version number.') gflags.DEFINE_string('filename', None, 'Input file name', short_name='f') gflags.RegisterValidator('my_version', lambda value: value % 2 == 0, message='--my_version must be divisible by 2') gflags.MarkFlagAsRequired('filename') NOTE ON --flagfile: Flags may be loaded from text files in addition to being specified on the commandline. Any flags you don't feel like typing, throw them in a file, one flag per line, for instance: --myflag=myvalue --nomyboolean_flag You then specify your file with the special flag '--flagfile=somefile'. You CAN recursively nest flagfile= tokens OR use multiple files on the command line. Lines beginning with a single hash '#' or a double slash '//' are comments in your flagfile. Any flagfile= will be interpreted as having a relative path from the current working directory rather than from the place the file was included from: myPythonScript.py --flagfile=config/somefile.cfg If somefile.cfg includes further --flagfile= directives, these will be referenced relative to the original CWD, not from the directory the including flagfile was found in! The caveat applies to people who are including a series of nested files in a different dir than they are executing out of. Relative path names are always from CWD, not from the directory of the parent include flagfile. We do now support '~' expanded directory names. Absolute path names ALWAYS work! EXAMPLE USAGE: FLAGS = gflags.FLAGS # Flag names are globally defined! So in general, we need to be # careful to pick names that are unlikely to be used by other libraries. # If there is a conflict, we'll get an error at import time. gflags.DEFINE_string('name', 'Mr. President', 'your name') gflags.DEFINE_integer('age', None, 'your age in years', lower_bound=0) gflags.DEFINE_boolean('debug', False, 'produces debugging output') gflags.DEFINE_enum('gender', 'male', ['male', 'female'], 'your gender') def main(argv): try: argv = FLAGS(argv) # parse flags except gflags.FlagsError, e: print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) if FLAGS.debug: print 'non-flag arguments:', argv print 'Happy Birthday', FLAGS.name if FLAGS.age is not None: print 'You are a %d year old %s' % (FLAGS.age, FLAGS.gender) if __name__ == '__main__': main(sys.argv) KEY FLAGS: As we already explained, each module gains access to all flags defined by all the other modules it transitively imports. In the case of non-trivial scripts, this means a lot of flags ... For documentation purposes, it is good to identify the flags that are key (i.e., really important) to a module. Clearly, the concept of "key flag" is a subjective one. When trying to determine whether a flag is key to a module or not, assume that you are trying to explain your module to a potential user: which flags would you really like to mention first? We'll describe shortly how to declare which flags are key to a module. For the moment, assume we know the set of key flags for each module. Then, if you use the app.py module, you can use the --helpshort flag to print only the help for the flags that are key to the main module, in a human-readable format. NOTE: If you need to parse the flag help, do NOT use the output of --help / --helpshort. That output is meant for human consumption, and may be changed in the future. Instead, use --helpxml; flags that are key for the main module are marked there with a yes element. The set of key flags for a module M is composed of: 1. Flags defined by module M by calling a DEFINE_* function. 2. Flags that module M explictly declares as key by using the function DECLARE_key_flag() 3. Key flags of other modules that M specifies by using the function ADOPT_module_key_flags() This is a "bulk" declaration of key flags: each flag that is key for becomes key for the current module too. Notice that if you do not use the functions described at points 2 and 3 above, then --helpshort prints information only about the flags defined by the main module of our script. In many cases, this behavior is good enough. But if you move part of the main module code (together with the related flags) into a different module, then it is nice to use DECLARE_key_flag / ADOPT_module_key_flags and make sure --helpshort lists all relevant flags (otherwise, your code refactoring may confuse your users). Note: each of DECLARE_key_flag / ADOPT_module_key_flags has its own pluses and minuses: DECLARE_key_flag is more targeted and may lead a more focused --helpshort documentation. ADOPT_module_key_flags is good for cases when an entire module is considered key to the current script. Also, it does not require updates to client scripts when a new flag is added to the module. EXAMPLE USAGE 2 (WITH KEY FLAGS): Consider an application that contains the following three files (two auxiliary modules and a main module) File libfoo.py: import gflags gflags.DEFINE_integer('num_replicas', 3, 'Number of replicas to start') gflags.DEFINE_boolean('rpc2', True, 'Turn on the usage of RPC2.') ... some code ... File libbar.py: import gflags gflags.DEFINE_string('bar_gfs_path', '/gfs/path', 'Path to the GFS files for libbar.') gflags.DEFINE_string('email_for_bar_errors', 'bar-team@google.com', 'Email address for bug reports about module libbar.') gflags.DEFINE_boolean('bar_risky_hack', False, 'Turn on an experimental and buggy optimization.') ... some code ... File myscript.py: import gflags import libfoo import libbar gflags.DEFINE_integer('num_iterations', 0, 'Number of iterations.') # Declare that all flags that are key for libfoo are # key for this module too. gflags.ADOPT_module_key_flags(libfoo) # Declare that the flag --bar_gfs_path (defined in libbar) is key # for this module. gflags.DECLARE_key_flag('bar_gfs_path') ... some code ... When myscript is invoked with the flag --helpshort, the resulted help message lists information about all the key flags for myscript: --num_iterations, --num_replicas, --rpc2, and --bar_gfs_path. Of course, myscript uses all the flags declared by it (in this case, just --num_replicas) or by any of the modules it transitively imports (e.g., the modules libfoo, libbar). E.g., it can access the value of FLAGS.bar_risky_hack, even if --bar_risky_hack is not declared as a key flag for myscript. OUTPUT FOR --helpxml: The --helpxml flag generates output with the following structure: PROGRAM_BASENAME MAIN_MODULE_DOCSTRING ( [yes] DECLARING_MODULE FLAG_NAME FLAG_HELP_MESSAGE DEFAULT_FLAG_VALUE CURRENT_FLAG_VALUE FLAG_TYPE [OPTIONAL_ELEMENTS] )* Notes: 1. The output is intentionally similar to the output generated by the C++ command-line flag library. The few differences are due to the Python flags that do not have a C++ equivalent (at least not yet), e.g., DEFINE_list. 2. New XML elements may be added in the future. 3. DEFAULT_FLAG_VALUE is in serialized form, i.e., the string you can pass for this flag on the command-line. E.g., for a flag defined using DEFINE_list, this field may be foo,bar, not ['foo', 'bar']. 4. CURRENT_FLAG_VALUE is produced using str(). This means that the string 'false' will be represented in the same way as the boolean False. Using repr() would have removed this ambiguity and simplified parsing, but would have broken the compatibility with the C++ command-line flags. 5. OPTIONAL_ELEMENTS describe elements relevant for certain kinds of flags: lower_bound, upper_bound (for flags that specify bounds), enum_value (for enum flags), list_separator (for flags that consist of a list of values, separated by a special token). 6. We do not provide any example here: please use --helpxml instead. This module requires at least python 2.2.1 to run. iNspychecker.pythoncCsxytdtiD]b}ti|itj o@ti|i}t|\}}|dj o ||fSqqWtddS(sReturns the module that's calling into this module. We generally use this function to get the name of the module calling a DEFINE_foo... function. isNo module was foundN( trangetsystgetrecursionlimitt _getframet f_globalstglobalst_GetModuleObjectAndNametNonetAssertionError(tdepthtglobals_for_frametmodulet module_name((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetCallingModuleObjectAndNames cCs tdS(s?Returns the name of the module that's calling into this module.i(R (((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetCallingModulescCs ttS(s6Returns: (module object, module name) for this module.(RR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetThisModuleObjectAndNamest FlagsErrorcBseZdZRS(s$The base class for all flags errors.(t__name__t __module__t__doc__(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRst DuplicateFlagcBseZdZRS(s*Raised if there is a flag naming conflict.(RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRstCantOpenFlagFileErrorcBseZdZRS(sHRaised if flagfile fails to open: doesn't exist, wrong permissions, etc.(RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRst&DuplicateFlagCannotPropagateNoneToSwigcBseZdZRS(sBSpecial case of DuplicateFlag -- SWIG flag value can't be set to None. This can be raised when a duplicate flag is created. Even if allow_override is True, we still abort if the new value is None, because it's currently impossible to pass None default value back to SWIG. See FlagValues.SetDefault for details. (RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRstDuplicateFlagErrorcBseZdZddZRS(s=A DuplicateFlag whose message cites the conflicting definitions. A DuplicateFlagError conveys more information than a DuplicateFlag, namely the modules where the conflicting definitions occur. This class was created to avoid breaking external modules which depend on the existing DuplicateFlags interface. cCsw||_|i|dd}|djo t}n|i|dd}d|i||f}ti||dS(sCreate a DuplicateFlagError. Args: flagname: Name of the flag being redefined. flag_values: FlagValues object containing the first definition of flagname. other_flag_values: If this argument is not None, it should be the FlagValues object where the second definition of flagname occurs. If it is None, we assume that we're being called when attempting to create the flag a second time, and we use the module calling this one as the source of the second definition. tdefaults s=The flag '%s' is defined twice. First from %s, Second from %sN(tflagnametFindModuleDefiningFlagRRRt__init__(tselfRt flag_valuestother_flag_valuest first_modulet second_moduletmsg((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs   N(RRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRstIllegalFlagValuecBseZdZRS(s*The flag command line argument is illegal.(RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR"stUnrecognizedFlagcBseZdZRS(s!Raised if a flag is unrecognized.(RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR#stUnrecognizedFlagErrorcBseZddZRS(tcCs*||_||_ti|d|dS(NsUnknown command line flag '%s'(Rt flagvalueR#R(RRR&((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s  (RRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR$siPcCstii ptdjp tdjotSy]tititid}t i d|d}|djo|St t i dtSWn ttt ifj otSXdS(sFReturns: an integer, the width of help lines that is used in TextWrap.t1234thhii(tCOLUMNSN(RtstdouttisattyttermiosRtfcntlt _help_widthtioctlt TIOCGWINSZtstructtunpacktinttostgetenvt TypeErrortIOErrorterror(tdatatcolumns((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt GetHelpWidths+ cCs'|i}x"|o|d o|d }qW|o|do|ddio g}n|idg}tiig}|D]}|o ||qq~}t|t|i}|oBx?tt|D]'}||o||||||d jo t}n|d jo d}nt||jotdn|d jod}|}n*|}t||jotdn| p |djo|idd}n|i }tidti}g}xA|i D]3} t|} x|i | i D]\} } } | o|o ||jp| o||jo|ddjo|d }n|o||t| 7}q|t| | } nt|t| |jot|t| |joe|i |i || }d} t|d|jo|i |i |}qV|d7}nxMt|t| |jo/|| 7}|i || ||} |}qYW| o|| d7}q"q"W|o ||jp| o$||jo|i |i n%t|| jo|i dn|}qWd i |S( sWraps a given text to a maximum line length and returns it. We turn lines that only contain whitespace into empty lines. We keep new lines and tabs (e.g., we do not treat tabs as spaces). Args: text: text to wrap length: maximum length of a line, includes indentation if this is None then use GetHelpWidth() indent: indent for all but first line firstline_indent: indent for first line; if None, fall back to indent tabs: replacement for tabs Returns: wrapped text Raises: FlagsError: if indent not shorter than length FlagsError: if firstline_indent not shorter than length R%s"Indent must be shorter than lengths-First line indent must be shorter than lengtht s s([ ]*)( *)([^ ]+)iis N(RR;RARtreplacetstriptretcompilet MULTILINER<tfindalltrstriptappendRD(REtlengthtindenttfirstline_indentttabsRIttabs_are_whitespacet line_regextresultt text_linetold_result_lentspacest current_tabstword((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytTextWrapQsf         &:     ) cCs^|i}tidti}|id|}t|}tidd|ti}|S(s0Takes a __doc__ string and reformats it as help.s^[ ]+$R%s(?<=\S) (?=\S)RN(RPRQRRtMtsubRM(tdoctwhitespace_only_line((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DocToHelps   cCsfx_tiiD]N\}}t|dd|jo)|djotid}n||fSqWdS(s^Returns the module that defines a global environment, and its name. Args: globals_dict: A dictionary that should correspond to an environment providing the values of the globals. Returns: A pair consisting of (1) module object and (2) module name (a string). Returns (None, None) if the module could not be identified. t__dict__t__main__iN(NN(RtmodulestitemstgetattrRtargv(t globals_dicttnameR ((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs  cCsktid}x|idj o |i}qW|i}t|d}|djotid}n|S(sAReturns: string, name of the module from which execution started.iiN(RRtf_backRRRRn(t deepest_frametglobals_for_main_moduletmain_module_name((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetMainModules   t FlagValuescBseZdZdZedZdZdZdZdZ dZ dZ d Z d Z d Zd Zd5d Zd5dZdZdZdZdZdZdZdZdZdZdZdZdZdZeZ dZ!dZ"dZ#dZ$d Z%d!Z&d"d#Z'd"d$Z(d"d%Z)d"d&Z*d'Z+d(Z,d)d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2ed0Z3d1Z4d2Z5d5d3Z6d4Z7RS(6s1Registry of 'Flag' objects. A 'FlagValues' can then scan command line arguments, passing flag arguments through to the 'Flag' objects that it owns. It also provides easy access to the flag values. Typically only one 'FlagValues' object is needed by an application: gflags.FLAGS This class is heavily overloaded: 'Flag' objects are registered via __setitem__: FLAGS['longname'] = x # register a new flag The .value attribute of the registered 'Flag' objects can be accessed as attributes of this 'FlagValues' object, through __getattr__. Both the long and short name of the original 'Flag' objects can be used to access its value: FLAGS.longname # parsed flag value FLAGS.x # parsed flag value (short name) Command line arguments are scanned and passed to the registered 'Flag' objects through the __call__ method. Unparsed arguments, including argv[0] (e.g. the program name) are returned. argv = FLAGS(sys.argv) # scan command line arguments The original registered Flag objects can be retrieved through the use of the dictionary-like operator, __getitem__: x = FLAGS['longname'] # access the registered Flag object The str() operator of a 'FlagValues' object provides help for all of the registered 'Flag' objects. cCsEh|id list of defined flags. Returns: A dictionary. Its keys are module names (strings). Its values are lists of Flag objects. Rx(Ri(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytFlagsByModuleDictQscCs |idS(sReturns the dictionary of module_id -> list of defined flags. Returns: A dictionary. Its keys are module IDs (ints). Its values are lists of Flag objects. Ry(Ri(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytFlagsByModuleIdDictZscCs |idS(sReturns the dictionary of module_name -> list of key flags. Returns: A dictionary. Its keys are module names (strings). Its values are lists of Flag objects. Rz(Ri(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytKeyFlagsByModuleDictcscCs)|i}|i|gi|dS(s&Records the module that defines a specific flag. We keep track of which flag is defined by which module so that we can later sort the flags by module. Args: module_name: A string, the name of a Python module. flag: A Flag object, a flag that is key to the module. N(Rt setdefaultRV(RR tflagtflags_by_module((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_RegisterFlagByModulels cCs)|i}|i|gi|dS(sRecords the module that defines a specific flag. Args: module_id: An int, the ID of the Python module. flag: A Flag object, a flag that is key to the module. N(RRRV(Rt module_idRtflags_by_module_id((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_RegisterFlagByModuleIdys cCs@|i}|i|g}||jo|i|ndS(sSpecifies that a flag is a key flag for a module. Args: module_name: A string, the name of a Python module. flag: A Flag object, a flag that is key to the module. N(RRRV(RR Rtkey_flags_by_modulet key_flags((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_RegisterKeyFlagForModules  cCs9t|tp |i}nt|ii|gS(s*Returns the list of flags defined by a module. Args: module: A module object or a module name (a string). Returns: A new list of Flag objects. Caller may update this list as he wishes: none of those changes will affect the internals of this FlagValue object. (t isinstancetstrRtlistRtget(RR ((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetFlagsDefinedByModules  cCsqt|tp |i}n|i|}x>|ii|gD]$}||jo|i|qEqEW|S(s&Returns the list of key flags for a module. Args: module: A module object or a module name (a string) Returns: A new list of Flag objects. Caller may update this list as he wishes: none of those changes will affect the internals of this FlagValue object. (RRRRRRRV(RR RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_GetKeyFlagsForModules   cCs]xV|iiD]B\}}x3|D]+}|i|jp|i|jo|Sq&WqW|S(sReturn the name of the module defining this flag, or default. Args: flagname: Name of the flag to lookup. default: Value to return if flagname is not defined. Defaults to None. Returns: The name of the module which registered the flag with this name. If no such module exists (i.e. no flag with this name exists), we return default. (Rt iteritemsRpt short_name(RRRR tflagsR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs    cCs]xV|iiD]B\}}x3|D]+}|i|jp|i|jo|Sq&WqW|S(sReturn the ID of the module defining this flag, or default. Args: flagname: Name of the flag to lookup. default: Value to return if flagname is not defined. Defaults to None. Returns: The ID of the module which registered the flag with this name. If no such module exists (i.e. no flag with this name exists), we return default. (RRRpR(RRRRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytFindModuleIdDefiningFlags    cCstxm|iiD]Y\}}||ijo=y|||@ss%s: %sN(tsortedtVerifytgflags_validatorstErrortPrintFlagsWithValuesR"R(RRRtetmessage((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR4s cCsk|i}|i}|i|d|jotS|i}|dj o|i|d|jotStS(sChecks whether a Flag object is registered under some name. Note: this is non trivial: in addition to its normal name, a flag may have a short name too. In self.FlagDict(), both the normal and the short name are mapped to the same flag object. E.g., calling only "del FLAGS.short_name" is not unregistering the corresponding Flag object (it is still registered under the longer name). Args: flag_obj: A Flag object. Returns: A boolean: True iff flag_obj is registered under some name. N(RRpRRtTrueRR|(Rtflag_objt flag_dictRpR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt_FlagIsRegisteredGs    cCs|i}||jot|n||}||=|i|pF|i|i||i|i||i|i|ndS(sDeletes a previously-defined flag from a flag object. This method makes sure we can delete a flag by using del flag_values_object. E.g., gflags.DEFINE_integer('foo', 1, 'Integer flag.') del gflags.FLAGS.foo Args: flag_name: A string, the name of the flag to be deleted. Raises: AttributeError: When there is no registered flag named flag_name. N(RRRt'_FlagValues__RemoveFlagFromDictByModuleRRR(RRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRds   cCsCx<|iD].\}}x||jo|i|qWq WdS(sRemoves a flag object from a module -> list of flags dictionary. Args: flags_by_module_dict: A dictionary that maps module names to lists of flags. flag_obj: A flag object. N(Rtremove(Rtflags_by_module_dictRt unused_moduletflags_in_module((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__RemoveFlagFromDictByModules   cCsR|i}||jot|n||i||i||idS(s3Changes the default value of the named flag object.N(RRt SetDefaultRR(RRpRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs   cCs||ijS(s3Returns True if name is a value (flag) in the dict.(R(RRp((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt __contains__scCst|iS(N(titerR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__iter__scCst|}d}g}|i}|d |i|ddt}t|}d}x$|iD]\}}|ipqdn|djo|i|}nd|} ||} || } xtdt |D]} || } | i ddjoqn| i d| o&d|i | od||| s iN(RRtReadFlagsFromFilesR|RRltbooleantShortestUniquePrefixesRRAtfindt startswithRVRRitgetoptt gnu_getoptt GetoptErrortoptRtsplittextendtParseR$R(RRnt shortoptstlongoptsRt original_argvtshortest_matchesRpRtno_nametprefixt no_prefixtarg_idxtargt undefok_flagstunrecognized_optstargstoptlistt unparsed_argsRt arg_indext flag_namest short_optionRRtret_val((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__call__s  !        ((                   cCs+x$|iiD]}|iqWdS(s=Resets the values to the point before FLAGS(argv) was called.N(RtvaluestUnparse(Rtf((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytReset8scCst|iS(sEReturns: a list of the names and short names of all registered flags.(RR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytRegisteredFlags=scCs>h}x1|iD]#}|i|}|i|| directive.R%s --flagfile=is --flagfiles -flagfile=s -flagfilei(RRR(Rt flag_string((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__IsFlagFileDirectives  cCsv|ido!tii|tdiS|ido!tii|tdiStd|dS(sReturns filename from a flagfile_str of form -[-]flagfile=filename. The cases of --flagfile foo and -flagfile foo shouldn't be hitting this function, as they are dealt with in the level above this function. s --flagfile=s -flagfile=sHit illegal --flagfile type: %sN(RR4R?t expanduserRARPR(Rt flagfile_str((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytExtractFilenames !!c Cs1g}g}yt|d}Wn%tj o}td|nX|i}|i|i|x|D]}|ioqq|idp|idoqq|i|oZ|i |}||jo#|i ||} |i | q)t i id|fqq|i|iqqW|S(sTReturns the useful (!=comments, etc) lines from a file with flags. Args: filename: A string, the name of the flag file. parsed_file_list: A list of the names of the files we have already read. MUTATED BY THIS FUNCTION. Returns: List of strings. See the note below. NOTE(user): This function checks for a nested --flagfile= tag and handles the lower file recursively. It returns a list of all the lines that _could_ contain command flags. This is EVERYTHING except whitespace lines and comments (lines starting with '#' or '//'). trs#ERROR:: Unable to open flagfile: %st#s//s.Warning: Hit circular flagfile dependency: %s (topenR7Rt readlinestcloseRVR=Rt _FlagValues__IsFlagFileDirectiveRt_FlagValues__GetFlagFileLinesRRtstderrtwriteRP( Rtfilenametparsed_file_listt line_listtflag_line_listtfile_objte_msgRIt sub_filenametincluded_flags((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__GetFlagFileLiness2         cCs1g}|}g}x|o|d}|d}|i|o|djp |djo;|ptdntii|d}|d}n|i|}|i|i||q|i||djoPn|i dp | o|i d oPqqqW|o|i|n|S( s^Processes command line args, but also allow args to be read from file. Args: argv: A list of strings, usually sys.argv[1:], which may contain one or more flagfile directives of the form --flagfile="./filename". Note that the name of the program (sys.argv[0]) should be omitted. force_gnu: If False, --flagfile parsing obeys normal flag semantics. If True, --flagfile parsing instead follows gnu_getopt semantics. *** WARNING *** force_gnu=False may become the future default! Returns: A new list which has the original list combined with what we read from any flagfile(s). References: Global gflags.FLAG class instance. This function should be called before the normal FLAGS(argv) call. This function scans the input list for a flag that looks like: --flagfile=. Then it opens , reads all valid key and value pairs and inserts them into the input list between the first item of the list and any subsequent items in the list. Note that your application's flags are still defined the usual way using gflags DEFINE_flag() type functions. Notes (assuming we're getting a commandline of some sort as our input): --> Flags from the command line argv _should_ always take precedence! --> A further "--flagfile=" CAN be nested in a flagfile. It will be processed after the parent flag file is done. --> For duplicate flags, first one we hit should "win". --> In a flagfile, a line beginning with # or // is a comment. --> Entirely blank lines _should_ be ignored. iis --flagfiles -flagfiles--flagfile with no arguments--RR}( R!R"R4R?RRRR"RVRRi(RRnRR&t rest_of_argstnew_argvt current_argt flag_filename((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRFs2#    cCsOd}xB|iiD].}|idj o||id7}qqW|S(s2Returns a string with the flags assignments from this FlagValues object. This function ignores flags whose value is None. Each flag assignment is separated by a newline. NOTE: MUST mirror the behavior of the C++ CommandlineFlagsIntoString from http://code.google.com/p/google-gflags R%s N(RRRRt Serialize(RtsR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytFlagsIntoStrings cCs0t|d}|i|i|idS(sAppends all flags assignments from this FlagInfo object to a file. Output will be in the format of a flagfile. NOTE: MUST mirror the behavior of the C++ AppendFlagsIntoFile from http://code.google.com/p/google-gflags taN(RR$R4R (RR%tout_file((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytAppendFlagsIntoFilesc Cs|pti}|id|idd}t|dtiitid|tidi }|pdtid}n|i dtid}t|d |||i t }|i }t|i}|ix|D]}}g}||D]} || i| fq~} | ix<| D]4\} } | |j} | i||d | d |q4WqW|id |id S(sOutputs flag documentation in XML format. NOTE: We use element names that are consistent with those used by the C++ command-line flag library, from http://code.google.com/p/google-gflags We also use a few new elements (e.g., ), but we do not interfere / overlap with existing XML elements used by the C++ library. Please maintain this consistency. Args: outfile: File object we write to. Default None means sys.stdout. s s s tprogramiRjs USAGE: %s [flags] s%stusagetis_keyRXs N(RR*R$t_WriteSimpleXMLElementR4R?tbasenameRnRkRRORRuRRtkeysRRptWriteInfoInXMLFormattflush(RtoutfileRXt usage_docRRtall_module_namesR RHRt flag_listtunused_flag_nameRR:((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytWriteHelpInXMLFormats4     .    cCs;x4|iD]&}|i|}|ii|q WdS(sRegister new flags validator to be checked. Args: validator: gflags_validators.Validator Raises: AttributeError: if validators work with a non-existing flag. N(t GetFlagsNamesRRRV(RRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt AddValidators N(8RRRRRR{RRRRRRRRRRRRRRRRRRRRRRRRRRthas_keyRRRRRRRRRRRRRRRR!RR"RR4R7RERG(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRv sh                 "            %  $   6 E  .cCs/yt|SWntj ot|SXdS(sCConverts value to a python string or, if necessary, unicode-string.N(RtUnicodeEncodeErrortunicode(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt _StrOrUnicodescCs:ti|}tidd|}|idd}|S(s>Escapes <, >, and & from s, and removes XML 1.0-illegal chars.s[\x00-\x08\x0b\x0c\x0e-\x1f]R%tasciitxmlcharrefreplace(tcgitescapeRQRetencode(R3((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt _MakeXMLSafescCsYt|}t|to|i}nt|}|id||||fdS(s9Writes a simple XML element. Args: outfile: File object we write the XML element to. name: A string, the name of XML element. value: A Python object, whose string representation will be used as the value of the XML element. indent: A string, prepended to each line of generated output. s%s<%s>%s N(RKRtbooltlowerRQR$(R@RpRRXt value_strtsafe_value_str((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR;s  RcBseZdZddddZdZdZdZdZdZ dZ d Z d Z d Z ed d ZdZRS(swInformation about a command-line flag. 'Flag' objects define the following fields: .name - the name for this flag .default - the default value for this flag .default_as_str - default value as repr'd string, e.g., "'true'" (or None) .value - the most recent parsed value of this flag; set by Parse() .help - a help string or None if no help is available .short_name - the single letter alias for this flag (or None) .boolean - if 'true', this flag does not accept arguments .present - true if this flag was parsed from command line flags. .parser - an ArgumentParser object .serializer - an ArgumentSerializer object .allow_override - the flag may be redefined without raising an error The only public method of a 'Flag' object is Parse(), but it is typically only called by a 'FlagValues' object. The Parse() method is a thin wrapper around the 'ArgumentParser' Parse() method. The parsed value is saved in .value, and the .present attribute is updated. If this flag was already present, a FlagsError is raised. Parse() is also called during __init__ to parse the default value and initialize the .value attribute. This enables other python modules to safely use flags even if the __main__ module neglects to parse the command line arguments. The .present attribute is cleared after __init__ parsing. If the default value is set to None, then the __init__ parsing step is skipped and the .value attribute is initialized to None. Note: The default value is also presented to the user in the help string, so it is important that it be a legal value for this flag. ic Cs|||_|p d}n||_||_||_d|_||_||_||_d|_ g|_ |i |dS(Ns(no help available)i( RpRRRtpresentRt serializerRRRRR( RRRWRpRt help_stringRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR1s           cCstt|S(N(thashR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__hash__DscCs ||jS(N((Rtother((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__eq__GscCs+t|tot|t|jStS(N(RRRtNotImplemented(RR[((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__lt__JscCsm|djodS|iot|ii|S|io |o tdStdSntt|S(Nttruetfalse(RRWtreprR2RRK(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt__GetParsedValueAsStringOs    cCs`y|ii||_Wn1tj o%}td|i||fnX|id7_dS(Nsflag --%s=%s: %si(RRRt ValueErrorR"RpRV(RtargumentR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR[s !cCs:|idjo d|_n|i|id|_dS(Ni(RRRRRV(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRbs cCs|idjodS|io%|io d|iSd|iSnB|iptd|ind|i|ii|ifSdS(NR%s--%ss--no%ss"Serializer not present for flag %ss--%s=%s(RRRRpRWRR2(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR2is    cCsV|djo|iot|in||_|i|i|i|_dS(s@Changes the default value (and current value too) for this Flag.N( RRRRpRRt_Flag__GetParsedValueAsStringRR(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRvs   cCs |iiS(s7Returns: a string that describes the type of this Flag.(RtType(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRfsR%cCsQ|i|d|d}|ot|dd|nt|d||t|d|i||iot|d|i|n|iot|d|i|n|io-t|it o|ii |i}n |i}t|d ||t|d |i |t|d |i ||i |||i|d d S(s-Writes common info about this flag, in XML format. This is information that is relevant to all flags (e.g., name, meaning, etc.). If you defined a flag that has some other pieces of info, then please override _WriteCustomInfoInXMLFormat. Please do NOT override this method. Args: outfile: File object we write to. module_name: A string, the name of the module that defines this flag. is_key: A boolean, True iff this flag is key for main module. indent: A string that is prepended to each generated line. s s RtyestfileRpRtmeaningRtcurrentRs N( R$R;RpRRRWRRRR2RRft_WriteCustomInfoInXMLFormat(RR@R R:RXt inner_indenttdefault_serialized((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR>s&     cCs|ii||dS(sWrites extra info about this flag, in XML format. "Extra" means "not already printed by WriteInfoInXMLFormat above." Args: outfile: File object we write to. indent: A string that is prepended to each generated line. N(RtWriteCustomInfoInXMLFormat(RR@RX((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRks N(RRRRRRZR\R^ReRRR2RRfR|R>Rk(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs        )t_ArgumentParserCachecBseZdZhZdZRS(s?Metaclass used to cache and share argument parsers among flags.cOs|oti|||S|i}|ft|}y ||SWnKtj o |i|ti||Stj oti||SXdS(sTReturns an instance of the argument parser cls. This method overrides behavior of the __new__ methods in all subclasses of ArgumentParser (inclusive). If an instance for mcs with the same set of arguments exists, this instance is returned, otherwise a new instance is created. If any keyword arguments are defined, or the values in args are not hashable, this method always returns a new instance of cls. Args: args: Positional initializer arguments. kwargs: Initializer keyword arguments. Returns: An instance of cls, shared or new. N(RRt _instancesttupletKeyErrorRR6(tmcsRtkwargst instancesR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRs  (RRRRpR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRostArgumentParsercBs5eZdZeZdZdZdZdZRS(sBase class used to parse and convert arguments. The Parse() method checks to make sure that the string argument is a legal value and convert it to a native type. If the value cannot be converted, it should throw a 'ValueError' exception with a human readable explanation of why the value is illegal. Subclasses should also define a syntactic_help string which may be presented to the user to describe the form of the legal values. Argument parser classes must be stateless, since instances are cached and shared between flags. Initializer arguments are allowed, but all member variables must be derived from initializer arguments only. R%cCs|S(s?Default implementation: always returns its argument unmodified.((RRd((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRscCsdS(Ntstring((R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRfscCsdS(N((RR@RX((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRn s( RRRRot __metaclass__R RRfRn(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRvs   tArgumentSerializercBseZdZdZRS(sABase class for generating string representations of a flag value.cCs t|S(N(RK(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR2s(RRRR2(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRystListSerializercBseZdZdZRS(cCs ||_dS(N(tlist_sep(RR{((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRscCs1|iig}|D]}|t|q~S(N(R{RDRK(RRRHtx((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR2s(RRRR2(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRzs sFlag validation failedcCs |iti|||dS(sAdds a constraint, which will be enforced during program execution. The constraint is validated when flags are initially parsed, and after each change of the corresponding flag's value. Args: flag_name: string, name of the flag to be checked. checker: method to validate the flag. input - value of the corresponding flag (string, boolean, etc. This value will be passed to checker by the library). See file's docstring for examples. output - Boolean. Must return True if validator constraint is satisfied. If constraint is not satisfied, it should either return False or raise gflags_validators.Error(desired_error_message). message: error text to be shown to the user if checker returns False. If checker raises gflags_validators.Error, message from the raised Error will be shown. flag_values: FlagValues Raises: AttributeError: if flag_name is not registered as a valid flag name. N(RGRtSimpleValidator(RtcheckerRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytRegisterValidator"scCs$t|ddd|d|dS(s"Ensure that flag is not None during program execution. Registers a flag validator, which will follow usual validator rules. Args: flag_name: string, name of the flag flag_values: FlagValues Raises: AttributeError: if flag_name is not registered as a valid flag name. cSs |dj S(N(R(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRLsRsFlag --%s must be specified.RN(R(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytMarkFlagAsRequired@s   csJidj pidj o&fd}t||d|ndS(sEnforce lower and upper bounds for numeric flags. Args: parser: NumericParser (either FloatParser or IntegerParser). Provides lower and upper bounds, and help text to display. name: string, name of the flag flag_values: FlagValues csG|dj o6i|o&d|if}ti|ntS(Ns %s is not %s(RtIsOutsideBoundsR RRR(RR(R(sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytChecker\sRN(t lower_boundRt upper_boundR(RRpRR((RsL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt _RegisterBoundsValidatorIfNeededQs cKs&tt|||||||dS(sRegisters a generic Flag object. NOTE: in the docstrings of all DEFINE* functions, "registers" is short for "creates a new flag and registers it". Auxiliary function: clients should use the specialized DEFINE_ function instead. Args: parser: ArgumentParser that is used to parse the flag arguments. name: A string, the flag name. default: The default value of the flag. help: A help string. flag_values: FlagValues object the flag will be registered with. serializer: ArgumentSerializer that serializes the flag value. args: Dictionary with extra keyword args that are passes to the Flag __init__. N(t DEFINE_flagR(RRpRRRRWR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINEjscCs`|}|||i~d||tdjoDtg}ti i D]}||iq~dtd|ndS(s@Declares that all flags key to a module are key to the current module. Args: module: A module object. flag_values: A FlagValues object. This should almost never need to be overridden. Raises: FlagsError: When given an argument that is a module name (a string), instead of a module object. s2Received module name %s; expected a module object.RiRN( RRRRRRRpRRRR(R RRHRt_[2]((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytADOPT_module_key_flagss00cKs2t}t}t|||||||dS(s/Registers a flag whose value can be any string.N(RvRyR(RpRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DEFINE_string s  t BooleanParsercBs)eZdZdZdZdZRS(sParser of boolean values.cCsxt|tjo4|id jotS|id jotSnt|}||jo|Std|dS( s?Converts the argument to a boolean; raise ValueError on errors.R_ttt1R`Rt0s$Non-boolean argument to boolean flagN(strueRR(sfalseRR(RRRSRR|RRRc(RRdt bool_argument((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytConvert s   cCs|i|}|S(N(R(RRdtval((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR$ scCsdS(NRR((R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf( s(RRRRRRf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s  t BooleanFlagcBseZdZddZRS(sBasic boolean flag. Boolean flags do not take any arguments, and their value is either True (1) or False (0). The false value is specified on the command line by prepending the word 'no' to either the long or the short flag name. For example, if a Boolean flag was created whose long name was 'update' and whose short name was 'x', then this flag could be explicitly unset through either --noupdate or --nox. c KsIt}ti||d||||d||ip d|_ndS(Nisa boolean value(RRRRR(RRpRRRRtp((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR9 s % N(RRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR, s cKs tt|||||dS(saRegisters a boolean flag. Such a boolean flag does not take an argument. If a user wants to specify a false value explicitly, the long option beginning with 'no' must be used: i.e. --noflag This flag will have a value of None, True or False. None is possible if default=None and the user does not specify the flag on the command line. N(RR(RpRRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_boolean? s tHelpFlagcBs eZdZdZdZRS(s HelpFlag is a special boolean flag that prints usage information and raises a SystemExit exception if it is ever found in the command line arguments. Note this is called with allow_override=1, so other apps can define their own --help flag, replacing this one, if they want. c Cs&ti|ddddddddS(NRisshow this helpRt?Ri(RR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRX scCsd|oYtidi}tt}|pdtidGH|odGH|GHntidndS(NRjs USAGE: %s [flags] isflags:i(RRkRRtFLAGSRntexit(RRRfR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR[ s  (RRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRQ s t HelpXMLFlagcBs eZdZdZdZRS(s8Similar to HelpFlag, but generates output in XML format.cCs ti|dtddddS(Nthelpxmls%like --help, but generates XML outputRi(RRR|(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf scCs,|o!tititidndS(Ni(RRERR*R(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRj s(RRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRd s t HelpshortFlagcBs eZdZdZdZRS(sB HelpshortFlag is a special boolean flag that prints usage information for the "main" module, and rasies a SystemExit exception if it is ever found in the command line arguments. Note this is called with allow_override=1, so other apps can define their own --helpshort flag, replacing this one, if they want. cCs ti|ddddddS(Nt helpshortisshow usage only for this moduleRi(RR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRv scCsd|oYtidi}ti}|pdtidGH|odGH|GHntidndS(NRjs USAGE: %s [flags] isflags:i(RRkRRRRnR(RRRfR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRy s  (RRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRn s t NumericParsercBs2eZdZdZdZdZdZRS(s]Parser of numeric values. Parsed value may be bounded to a given upper and lower bound. cCs=|idj o||ijp|idj o ||ijS(N(RRR(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s cCs@|i|}|i|otd||ifn|S(Ns %s is not %s(RRRcR (RRdR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR scCsX|idj ot|d|i|n|idj ot|d|i|ndS(NRR(RRR;R(RR@RX((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRn scCs|S(s?Default implementation: always returns its argument unmodified.((RRd((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s(RRRRRRnR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s    t FloatParsercBsPeZdZdZdZdieefZdddZdZ dZ RS(sdParser of floating point values. Parsed value may be bounded to a given upper and lower bound. R5tnumberRNcCstt|i||_||_|i}|dj o$|dj od|||f}n|djod|i}ng|djod|i}nI|dj od|i|f}n%|dj od|i|f}n||_dS(Ns%s in the range [%s, %s]isa non-negative %ssa non-positive %ss%s <= %ss%s >= %s(tsuperRRRRR Rt number_name(RRRtsh((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s       cCs t|S(s:Converts argument to a float; raises ValueError on errors.(tfloat(RRd((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR scCsdS(NR((R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf sN( RRRtnumber_articleRRDR RRRRf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s c KsKt||}t}t|||||||t||d|dS(sRegisters a flag whose value must be a float. If lower_bound or upper_bound are set, then this flag must be within the given range. RN(RRyRR( RpRRRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DEFINE_float s t IntegerParsercBsPeZdZdZdZdieefZdddZdZ dZ RS(s_Parser of an integer value. Parsed value may be bounded to a given upper and lower bound. tantintegerRNcCs,tt|i||_||_|i}|dj o$|dj od|||f}n|djod|i}n|djod|i}n|djod|i}ng|djod|i}nI|dj od |i|f}n%|dj od |i|f}n||_dS( Ns%s in the range [%s, %s]is a positive %sis a negative %sisa non-negative %ssa non-positive %ss%s <= %ss%s >= %s(RRRRRR RR(RRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s&         cCszd}t|tjoSd}t|djo,|ddjo|ddjo d}nt||St|SdS( Nsno-returnvaluesi iiRiR|i(RRRAR3(RRdt __pychecker__tbase((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s5 cCsdS(NR3((R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf sN( RRRRRRDR RRRRf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s c KsKt||}t}t|||||||t||d|dS(sRegisters a flag whose value must be an integer. If lower_bound, or upper_bound are set, then this flag must be within the given range. RN(RRyRR( RpRRRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_integer s t EnumParsercBs,eZdZddZdZdZRS(sParser of a string enum value (a string value from a given set). If enum_values (see below) is not specified, any string is allowed. cCs tt|i||_dS(N(RRRt enum_values(RR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR! scCs>|io0||ijo tddi|in|S(Nsvalue should be one of <%s>t|(RRcRD(RRd((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR% scCsdS(Ns string enum((R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf+ sN(RRRRRRRf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s  tEnumFlagcBs&eZdZdddZdZRS(sFBasic enum flag; its value can be any string from list of enum_values.c Ks~|pg}t|}t}ti|||||||||ip d|_nddi||if|_dS(Nsan enum strings<%s>: %sR(RRyRRRRD( RRpRRRRRRtg((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR2 s   " cCs.x'|iiD]}t|d||q WdS(Nt enum_value(RRR;(RR@RXR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRk; s N(RRRRRRk(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR/ s cKs#tt||||||dS(s@Registers a flag whose value can be any string from enum_values.N(RR(RpRRRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DEFINE_enum@ stBaseListParsercBs/eZdZdddZdZdZRS(sBase class for a parser of lists of strings. To extend, inherit from this class; from the subclass __init__, call BaseListParser.__init__(self, token, name) where token is a character used to tokenize, and name is a description of the separator. cCsG|pttt|i||_||_d|i|_dS(Nsa %s separated list(RRRRt_tokent_nameR (RttokenRp((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRW s   cCs\t|to|S|djogSg}|i|iD]}||iq>~SdS(NR%(RRRRRP(RRdRHR3((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR^ s  cCs d|iS(Ns%s separated list of strings(R(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRff sN(RRRRRRRf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRL s  t ListParsercBs eZdZdZdZRS(s-Parser for a comma-separated list of strings.cCsti|dddS(NRtcomma(RR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRm scCs0ti|||t|dtd|dS(Ntlist_separatorR(RRnR;Ra(RR@RX((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRnp s(RRRRRn(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRj s tWhitespaceSeparatedListParsercBs eZdZdZdZRS(s2Parser for a whitespace-separated list of strings.cCsti|dddS(Nt whitespace(RRR(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRx scCs]ti|||tti}|ix*tiD]}t|dt||q6WdS(NR(RRnRRwRRR;Ra(RR@RXt separatorstws_char((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRn{ s   (RRRRRn(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRu s cKs5t}td}t|||||||dS(sBRegisters a flag whose value is a comma-separated list of strings.RN(RRzR(RpRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DEFINE_list s  cKs5t}td}t|||||||dS(sxRegisters a flag whose value is a whitespace-separated list of strings. Any whitespace can be used as a separator. RNN(RRzR(RpRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_spaceseplist s  t MultiFlagcBs2eZdZdZdZdZdZRS(sXA flag that can appear multiple time on the command-line. The value of such a flag is a list that contains the individual values from all the appearances of that flag on the command-line. See the __doc__ for Flag for most behavior of this class. Only differences in behavior are described here: * The default value may be either a single value or a list of values. A single value is interpreted as the [value] singleton list. * The value of the flag is always a list, even if the option was only supplied once, and even if the default value is a single value cOs&ti||||id7_dS(Ns4; repeat this option to specify a list of values(RRR(RRRt((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR scCsxt|tp |g}n|io |i}ng}x.|D]&}ti|||i|iqAW||_dS(sParses one or more arguments with the installed parser. Args: arguments: a single argument or a list of arguments (typically a list of default values); a single argument is converted internally into a list containing one item. N(RRRVRRRRV(Rt argumentsRtitem((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s   cCs|iptd|in|idjodSd}|i}x9|D]1|_|o|d7}n|ti|7}qLW||_|S(Ns"Serializer not present for flag %sR%RN(RWRRpRRRR2(RR3t multi_value((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR2 s    cCsd|iiS(Nsmulti (RRf(R((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyRf s(RRRRRR2Rf(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyR s    cKs&tt|||||||dS(s.Registers a generic MultiFlag that parses its args with a given parser. Auxiliary function. Normal users should NOT use it directly. Developers who need to create their own 'Parser' classes for options which can appear multiple times can call this module function to register their flags. N(RR(RRWRpRRRR((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyt DEFINE_multi s cKs2t}t}t|||||||dS(sRegisters a flag whose value can be a list of any strings. Use the flag on the command line multiple times to place multiple string values into the list. The 'default' may be a single string (which will be converted into a single-element list) or a list of strings. N(RvRyR(RpRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_multistring s  c Ks8t||}t}t|||||||dS(s Registers a flag whose value can be a list of arbitrary integers. Use the flag on the command line multiple times to place multiple integer values into the list. The 'default' may be a single integer (which will be converted into a single-element list) or a list of integers. N(RRyR( RpRRRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_multi_int s  c Ks8t||}t}t|||||||dS(sRegisters a flag whose value can be a list of arbitrary floats. Use the flag on the command line multiple times to place multiple float values into the list. The 'default' may be a single float (which will be converted into a single-element list) or a list of floats. N(RRyR( RpRRRRRRRRW((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pytDEFINE_multi_float s  tflagfilesBInsert flag definitions from the given file into the command line.tundefokscomma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name. IMPORTANT: flags in this list that have arguments MUST use the --flag=value format.(RRRNRR4RQRwR1RR-t ImportErrorRR,RRkRR RRt ExceptionRRRRRR"R#R$RR.R;RMRcRhRRuRvRRKRQR;RRRotobjectRvRyRzRRRRRRRRRRRRt DEFINE_boolRRRRRRRRRRRRRRRRRRRRRR(((sL/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/python_gflags/gflags.pyts              #   +q       (    ! '   !# ,     H