[Python-checkins] cpython (2.7): De-'colour'ize stdlib except for idlelib.configDialog.

terry.reedy python-checkins at python.org
Fri Oct 10 00:45:33 CEST 2014


https://hg.python.org/cpython/rev/f3c9fbfe7b58
changeset:   92901:f3c9fbfe7b58
branch:      2.7
parent:      92890:de4ffe244440
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Thu Oct 09 18:44:26 2014 -0400
summary:
  De-'colour'ize stdlib except for idlelib.configDialog.
Tweak docstrigs and comments in affected functions in idlelib.configHandler.

files:
  Demo/turtle/demohelp.txt     |   2 +-
  Demo/turtle/tdemo_chaos.py   |   4 +-
  Lib/idlelib/EditorWindow.py  |   2 +-
  Lib/idlelib/configHandler.py |  36 ++++++++++++-----------
  Lib/lib-tk/tkColorChooser.py |   4 +-
  5 files changed, 25 insertions(+), 23 deletions(-)


diff --git a/Demo/turtle/demohelp.txt b/Demo/turtle/demohelp.txt
--- a/Demo/turtle/demohelp.txt
+++ b/Demo/turtle/demohelp.txt
@@ -15,7 +15,7 @@
   (1) How to use the demo viewer.
 
   Select a demoscript from the example menu.
-  The (syntax coloured) source code appears in the left
+  The (syntax colored) source code appears in the left
   source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
 
   - Press START button to start the demo.
diff --git a/Demo/turtle/tdemo_chaos.py b/Demo/turtle/tdemo_chaos.py
--- a/Demo/turtle/tdemo_chaos.py
+++ b/Demo/turtle/tdemo_chaos.py
@@ -29,8 +29,8 @@
     line(-1, 0, N+1, 0)
     line(0, -0.1, 0, 1.1)
 
-def plot(fun, start, colour):
-    pencolor(colour)
+def plot(fun, start, color):
+    pencolor(color)
     x = start
     jumpto(0, x)
     pendown()
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -781,7 +781,7 @@
         self.color = None
 
     def ResetColorizer(self):
-        "Update the colour theme"
+        "Update the color theme"
         # Called from self.filename_change_hook and from configDialog.py
         self._rmcolorizer()
         self._addcolorizer()
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -275,25 +275,27 @@
         return cfgParser.sections()
 
     def GetHighlight(self, theme, element, fgBg=None):
-        """Return individual highlighting theme elements.
+        """Return individual theme element highlight color(s).
 
-        fgBg - string ('fg'or'bg') or None, if None return a dictionary
-        containing fg and bg colours (appropriate for passing to Tkinter in,
-        e.g., a tag_config call), otherwise fg or bg colour only as specified.
+        fgBg - string ('fg' or 'bg') or None.
+        If None, return a dictionary containing fg and bg colors with
+        keys 'foreground' and 'background'.  Otherwise, only return
+        fg or bg color, as specified.  Colors are intended to be
+        appropriate for passing to Tkinter in, e.g., a tag_config call).
         """
         if self.defaultCfg['highlight'].has_section(theme):
             themeDict = self.GetThemeDict('default', theme)
         else:
             themeDict = self.GetThemeDict('user', theme)
         fore = themeDict[element + '-foreground']
-        if element == 'cursor': #there is no config value for cursor bg
+        if element == 'cursor':  # There is no config value for cursor bg
             back = themeDict['normal-background']
         else:
             back = themeDict[element + '-background']
         highlight = {"foreground": fore, "background": back}
-        if not fgBg: #return dict of both colours
+        if not fgBg:  # Return dict of both colors
             return highlight
-        else: #return specified colour only
+        else:  # Return specified color only
             if fgBg == 'fg':
                 return highlight["foreground"]
             if fgBg == 'bg':
@@ -315,11 +317,11 @@
             cfgParser = self.defaultCfg['highlight']
         else:
             raise InvalidTheme('Invalid theme type specified')
-        #foreground and background values are provded for each theme element
-        #(apart from cursor) even though all these values are not yet used
-        #by idle, to allow for their use in the future. Default values are
-        #generally black and white.
-        # TODO make theme, a constant, a module or class attribute
+        # Provide foreground and background colors for each theme
+        # element (other than cursor) even though some values are not
+        # yet used by idle, to allow for their use in the future.
+        # Default values are generally black and white.
+        # TODO copy theme from a class attribute.
         theme ={'normal-foreground':'#000000',
                 'normal-background':'#ffffff',
                 'keyword-foreground':'#000000',
@@ -351,18 +353,18 @@
                 'console-background':'#ffffff' }
         for element in theme:
             if not cfgParser.has_option(themeName, element):
-                #we are going to return a default, print warning
-                warning = ('\n Warning: configHandler.py - IdleConf.GetThemeDict'
+                # Print warning that will return a default color
+                warning = ('\n Warning: configHandler.IdleConf.GetThemeDict'
                            ' -\n problem retrieving theme element %r'
                            '\n from theme %r.\n'
-                           ' returning default value: %r' %
+                           ' returning default color: %r' %
                            (element, themeName, theme[element]))
                 try:
                     print(warning, file=sys.stderr)
                 except IOError:
                     pass
-            colour = cfgParser.Get(themeName, element, default=theme[element])
-            theme[element] = colour
+            theme[element] = cfgParser.Get(
+                    themeName, element, default=theme[element])
         return theme
 
     def CurrentTheme(self):
diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/lib-tk/tkColorChooser.py
--- a/Lib/lib-tk/tkColorChooser.py
+++ b/Lib/lib-tk/tkColorChooser.py
@@ -1,4 +1,4 @@
-# tk common colour chooser dialogue
+# tk common color chooser dialogue
 #
 # this module provides an interface to the native color dialogue
 # available in Tk 4.2 and newer.
@@ -11,7 +11,7 @@
 #
 # options (all have default values):
 #
-# - initialcolor: colour to mark as selected when dialog is displayed
+# - initialcolor: color to mark as selected when dialog is displayed
 #   (given as an RGB triplet or a Tk color string)
 #
 # - parent: which window to place the dialog on top of

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list