A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2000-September/013546.html below:

[Python-checkins] CVS: distutils/distutils cmd.py,1.22,1.23

[Python-checkins] CVS: distutils/distutils cmd.py,1.22,1.23Greg Ward python-dev@python.org
Sat, 16 Sep 2000 08:09:21 -0700
Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv7448

Modified Files:
	cmd.py 
Log Message:
Added the "sub-command" machinery to formalize the notion of "command 
families" -- eg. install and its brood, build and its brood, and so forth.
Specifically: added the 'sub_commands' class attribute (empty list, sub-
classes must override it) and a comment describing it, and the
'get_sub_commands()' method.

Index: cmd.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/cmd.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** cmd.py	2000/08/13 00:36:47	1.22
--- cmd.py	2000/09/16 15:09:17	1.23
***************
*** 32,35 ****
--- 32,52 ----
      """
  
+     # 'sub_commands' formalizes the notion of a "family" of commands,
+     # eg. "install" as the parent with sub-commands "install_lib",
+     # "install_headers", etc.  The parent of a family of commands
+     # defines 'sub_commands' as a class attribute; it's a list of
+     #    (command_name : string, predicate : unbound_method | string | None)
+     # tuples, where 'predicate' is a method of the parent command that
+     # determines whether the corresponding command is applicable in the
+     # current situation.  (Eg. we "install_headers" is only applicable if
+     # we have any C header files to install.)  If 'predicate' is None,
+     # that command is always applicable.
+     # 
+     # 'sub_commands' is usually defined at the *end* of a class, because
+     # predicates can be unbound methods, so they must already have been
+     # defined.  The canonical example is the "install" command.
+     sub_commands = []
+ 
+ 
      # -- Creation/initialization methods -------------------------------
  
***************
*** 309,312 ****
--- 326,343 ----
          """
          self.distribution.run_command (command)
+ 
+ 
+     def get_sub_commands (self):
+         """Determine the sub-commands that are relevant in the current
+         distribution (ie., that need to be run).  This is based on the
+         'sub_commands' class attribute: each tuple in that list may include
+         a method that we call to determine if the subcommand needs to be
+         run for the current distribution.  Return a list of command names.
+         """
+         commands = []
+         for (cmd_name, method) in self.sub_commands:
+             if method is None or method(self):
+                 commands.append(cmd_name)
+         return commands
  
  




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4