Coverage for configman.value_sources.for_getopt : 92%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is configman # # The Initial Developer of the Original Code is # Mozilla Foundation # Portions created by the Initial Developer are Copyright (C) 2011 # the Initial Developer. All Rights Reserved. # # Contributor(s): # K Lars Lohn, lars@mozilla.com # Peter Bengtsson, peterbe@mozilla.com # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK *****
It uses getopt in its implementation. It is thought that this implementation will be supplanted by the argparse implementation when using Python 2.7 or greater.
This module declares that its ValueSource constructor implementation can handle the getopt module or a list. If specified as the getopt module, the constructor will fetch the source of argv from the configmanager that was passed in. If specified as a list, the constructor will assume the list represents the argv source."""
list, # a list of options to serve as the argv source )
"""The ValueSource implementation for the getopt module. This class will interpret an argv list of commandline arguments using getopt.""" else: raise CantHandleTypeException("don't know how to handle" " %s." % str(source))
"""This is the black sheep of the crowd of ValueSource implementations. It needs to know ahead of time all of the parameters that it will need, but we cannot give it. We may not know all the parameters because not all classes may have been expanded yet. The two parameters allow this ValueSource implementation to know what the parameters have already been defined. The 'ignore_mismatches' parameter tells the implementation if it can or cannot ignore extraneous commandline options. The last time this function is called, it will be required to test for illegal commandline options and respond accordingly.""" long_options_list = self.getopt_create_opts( config_manager.option_definitions) else: # here getopt looks through the command line arguments and # consumes the defined switches. The things that are not # consumed are then offered as the 'args' variable of the # parent configuration_manager short_options_str, long_options_list) else: config_manager.option_definitions, '') raise NotAnOptionError('%s is not a valid short' ' form option' % opt_name[1:]) else:
"", short_options_list, long_options_list)
prefix, short_options_list, long_options_list): else: except AttributeError: pass else: else: # Namespace case new_prefix, short_options_list, long_options_list)
#-------------------------------------------------------------------------- """my_getopt(args, options[, long_options]) -> opts, args
This function works like gnu_getopt(), except that unknown parameters are ignored rather than raising an error. """ longopts = [longopts] else: prog_args += args[1:] break longopts, args[1:]) args[1:]) else:
#-------------------------------------------------------------------------- new_prefix) else: except KeyError: continue |