[Python-checkins] CVS: distutils/distutils dist.py,1.17,1.18

Greg Ward python-dev@python.org
Thu, 25 May 2000 18:00:19 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2997

Modified Files:
	dist.py 
Log Message:
Factored out code for extracting-or-creating one of the option
  dictionaries in 'self.command_options' to 'get_option_dict()'.
Simplified code in 'parse_config_files()' and 'parse_command_line()'
  accordingly.
Fixed code in constructor that processes the 'options' dictionary
  from the setup script so it actually works: uses the new
  'self.command_options' dictionary rather than creating command
  objects and calling 'set_option()' on them.


Index: dist.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/dist.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** dist.py	2000/05/23 04:11:14	1.17
--- dist.py	2000/05/26 01:00:15	1.18
***************
*** 7,11 ****
  # (extricated from core.py; actually dates back to the beginning)
  
! __revision__ = "$Id: dist.py,v 1.17 2000/05/23 04:11:14 gward Exp $"
  
  import sys, os, string, re
--- 7,11 ----
  # (extricated from core.py; actually dates back to the beginning)
  
! __revision__ = "$Id: dist.py,v 1.18 2000/05/26 01:00:15 gward Exp $"
  
  import sys, os, string, re
***************
*** 186,194 ****
                  del attrs['options']
                  for (command, cmd_options) in options.items():
!                     cmd_obj = self.get_command_obj (command)
!                     for (key, val) in cmd_options.items():
!                         cmd_obj.set_option (key, val)
!                 # loop over commands
!             # if any command options                        
  
              # Now work on the rest of the attributes.  Any attribute that's
--- 186,192 ----
                  del attrs['options']
                  for (command, cmd_options) in options.items():
!                     opt_dict = self.get_option_dict(command)
!                     for (opt, val) in cmd_options.items():
!                         opt_dict[opt] = ("setup script", val)
  
              # Now work on the rest of the attributes.  Any attribute that's
***************
*** 206,209 ****
--- 204,220 ----
  
  
+     def get_option_dict (self, command):
+         """Get the option dictionary for a given command.  If that
+         command's option dictionary hasn't been created yet, then create it
+         and return the new dictionary; otherwise, return the existing
+         option dictionary.
+         """
+ 
+         dict = self.command_options.get(command)
+         if dict is None:
+             dict = self.command_options[command] = {}
+         return dict
+ 
+ 
      # -- Config file finding/parsing methods ---------------------------
  
***************
*** 267,277 ****
              for section in parser.sections():
                  options = parser.options(section)
!                 if not self.command_options.has_key(section):
!                     self.command_options[section] = {}
!                 opts = self.command_options[section]
  
                  for opt in options:
                      if opt != '__name__':
!                         opts[opt] = (filename, parser.get(section,opt))
  
              # Make the ConfigParser forget everything (so we retain
--- 278,286 ----
              for section in parser.sections():
                  options = parser.options(section)
!                 opt_dict = self.get_option_dict(section)
  
                  for opt in options:
                      if opt != '__name__':
!                         opt_dict[opt] = (filename, parser.get(section,opt))
  
              # Make the ConfigParser forget everything (so we retain
***************
*** 410,418 ****
          # Put the options from the command-line into their official
          # holding pen, the 'command_options' dictionary.
!         if not self.command_options.has_key(command):
!             self.command_options[command] = {}
!         cmd_opts = self.command_options[command]
          for (name, value) in vars(opts).items():
!             cmd_opts[name] = ("command line", value)
  
          return args
--- 419,425 ----
          # Put the options from the command-line into their official
          # holding pen, the 'command_options' dictionary.
!         opt_dict = self.get_option_dict(command)
          for (name, value) in vars(opts).items():
!             opt_dict[name] = ("command line", value)
  
          return args