[Python-checkins] CVS: distutils/distutils archive_util.py,1.6,1.7 ccompiler.py,1.23,1.24 dist.py,1.28,1.29

Greg Ward python-dev@python.org
2000年6月23日 17:23:22 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv877
Modified Files:
	archive_util.py ccompiler.py dist.py 
Log Message:
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Index: archive_util.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/archive_util.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** archive_util.py	2000年06月07日 03:00:05	1.6
--- archive_util.py	2000年06月24日 00:23:20	1.7
***************
*** 111,118 ****
 
 ARCHIVE_FORMATS = {
! 'gztar': (make_tarball, [('compress', 'gzip')],"gzipped tar-file"),
! 'bztar': (make_tarball, [('compress', 'bzip2')],"bzip2-ed tar-file"),
! 'ztar': (make_tarball, [('compress', 'compress')],"compressed tar-file"),
! 'tar': (make_tarball, [('compress', None)],"uncompressed tar-file"),
 'zip': (make_zipfile, [],"zip-file")
 }
--- 111,118 ----
 
 ARCHIVE_FORMATS = {
! 'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
! 'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
! 'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"),
! 'tar': (make_tarball, [('compress', None)], "uncompressed tar file"),
 'zip': (make_zipfile, [],"zip-file")
 }
Index: ccompiler.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** ccompiler.py	2000年06月21日 02:58:46	1.23
--- ccompiler.py	2000年06月24日 00:23:20	1.24
***************
*** 743,760 ****
 # find the code that implements an interface to this compiler. (The module
 # is assumed to be in the 'distutils' package.)
! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',"standard UNIX-style compiler"),
! 'msvc': ('msvccompiler', 'MSVCCompiler',"Microsoft Visual C++"),
! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',"Cygwin-Gnu-Win32-C-Compiler"),
! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',"MinGW32-C-Compiler (or cygwin in this mode)"),
 }
 
- # prints all possible arguments to --compiler
 def show_compilers():
 from distutils.fancy_getopt import FancyGetopt 
! list_of_compilers=[]
 for compiler in compiler_class.keys():
! 	list_of_compilers.append(("compiler="+compiler,None,compiler_class[compiler][2]))
! list_of_compilers.sort()
! pretty_printer=FancyGetopt(list_of_compilers)
 pretty_printer.print_help("List of available compilers:")
 
--- 743,770 ----
 # find the code that implements an interface to this compiler. (The module
 # is assumed to be in the 'distutils' package.)
! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',
! "standard UNIX-style compiler"),
! 'msvc': ('msvccompiler', 'MSVCCompiler',
! "Microsoft Visual C++"),
! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',
! "Cygwin port of GNU C Compiler for Win32"),
! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',
! "Mingw32 port of GNU C Compiler for Win32"),
 }
 
 def show_compilers():
+ """Print list of available compilers (used by the "--help-compiler"
+ options to "build", "build_ext", "build_clib").
+ """
+ # XXX this "knows" that the compiler option it's describing is
+ # "--compiler", which just happens to be the case for the three
+ # commands that use it.
 from distutils.fancy_getopt import FancyGetopt 
! compilers = []
 for compiler in compiler_class.keys():
! 	compilers.append(("compiler="+compiler, None,
! compiler_class[compiler][2]))
! compilers.sort()
! pretty_printer = FancyGetopt(compilers)
 pretty_printer.print_help("List of available compilers:")
 
***************
*** 784,788 ****
 compiler = default_compiler[plat]
 
! (module_name, class_name,long_description) = compiler_class[compiler]
 except KeyError:
 msg = "don't know how to compile C/C++ code on platform '%s'" % plat
--- 794,798 ----
 compiler = default_compiler[plat]
 
! (module_name, class_name, long_description) = compiler_class[compiler]
 except KeyError:
 msg = "don't know how to compile C/C++ code on platform '%s'" % plat
Index: dist.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/dist.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** dist.py	2000年06月07日 03:00:05	1.28
--- dist.py	2000年06月24日 00:23:20	1.29
***************
*** 438,446 ****
 negative_opt.update (cmd_class.negative_opt)
 
! 	# Check for help_options in command class
! 	# They have a different format (tuple of four) so we need to preprocess them here 
! 	help_options = []
! 	if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
! 	 help_options = map(lambda x:(x[0],x[1],x[2]),cmd_class.help_options)
 
 # All commands support the global options too, just by adding
--- 438,449 ----
 negative_opt.update (cmd_class.negative_opt)
 
! 	# Check for help_options in command class. They have a different
! 	# format (tuple of four) so we need to preprocess them here.
! 	if (hasattr(cmd_class, 'help_options') and
! type (cmd_class.help_options) is ListType):
! help_options = fix_help_options(cmd_class.help_options)
! else:
! help_optiosn = []
! 
 
 # All commands support the global options too, just by adding
***************
*** 454,463 ****
 return
 
! 	if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
 	 help_option_found=0
 	 for help_option in cmd_class.help_options:
 		if hasattr(opts, parser.get_attr_name(help_option[0])):
 		 help_option_found=1
! 		 #print "showing help for option %s of command %s" % (help_option[0],cmd_class)
 		 if callable(help_option[3]):
 			help_option[3]()
--- 457,468 ----
 return
 
! 	if (hasattr(cmd_class, 'help_options') and
! type (cmd_class.help_options) is ListType):
 	 help_option_found=0
 	 for help_option in cmd_class.help_options:
 		if hasattr(opts, parser.get_attr_name(help_option[0])):
 		 help_option_found=1
! 		 #print "showing help for option %s of command %s" % \
! # (help_option[0],cmd_class)
 		 if callable(help_option[3]):
 			help_option[3]()
***************
*** 519,525 ****
 else:
 klass = self.get_command_class (command)
! 	 if hasattr(klass,"help_options") and type (klass.help_options) is ListType:
! 		parser.set_option_table (klass.user_options+
! 					 map(lambda x:(x[0],x[1],x[2]),klass.help_options))
 	 else:
 	parser.set_option_table (klass.user_options)
--- 524,531 ----
 else:
 klass = self.get_command_class (command)
! 	 if (hasattr(klass, 'help_options') and
! type (klass.help_options) is ListType):
! 		parser.set_option_table (klass.user_options +
! fix_help_options(klass.help_options))
 	 else:
 	parser.set_option_table (klass.user_options)
***************
*** 890,893 ****
--- 896,910 ----
 
 # class DistributionMetadata
+ 
+ 
+ def fix_help_options (options):
+ """Convert a 4-tuple 'help_options' list as found in various command
+ classes to the 3-tuple form required by FancyGetopt.
+ """
+ new_options = []
+ for help_tuple in options:
+ new_options.append(help_tuple[0:3])
+ return new_options
+ 
 
 if __name__ == "__main__":

AltStyle によって変換されたページ (->オリジナル) /