[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57482] branches/soc-2013-cycles_mblur/ scons: Commit changes to scons that came in on r57479.

Gavin Howard gavin.d.howard at gmail.com
Sat Jun 15 23:13:13 CEST 2013


Revision: 57482
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57482
Author:   gdh
Date:     2013-06-15 21:13:13 +0000 (Sat, 15 Jun 2013)
Log Message:
-----------
Commit changes to scons that came in on r57479.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57479

Modified Paths:
--------------
    branches/soc-2013-cycles_mblur/scons/scons-time.py
    branches/soc-2013-cycles_mblur/scons/scons.py
    branches/soc-2013-cycles_mblur/scons/sconsign.py

Modified: branches/soc-2013-cycles_mblur/scons/scons-time.py
===================================================================
--- branches/soc-2013-cycles_mblur/scons/scons-time.py	2013-06-15 21:00:06 UTC (rev 57481)
+++ branches/soc-2013-cycles_mblur/scons/scons-time.py	2013-06-15 21:13:13 UTC (rev 57482)
@@ -9,7 +9,7 @@
 #
 
 #
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -29,36 +29,58 @@
 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
+from __future__ import division
 from __future__ import nested_scopes
 
-__revision__ = "src/script/scons-time.py 4043 2009/02/23 09:06:45 scons"
+__revision__ = "src/script/scons-time.py  2013/03/03 09:48:35 garyo"
 
 import getopt
 import glob
 import os
-import os.path
 import re
 import shutil
-import string
 import sys
 import tempfile
 import time
 
 try:
-    False
+    sorted
 except NameError:
-    # Pre-2.2 Python has no False keyword.
-    import __builtin__
-    __builtin__.False = not 1
+    # Pre-2.4 Python has no sorted() function.
+    #
+    # The pre-2.4 Python list.sort() method does not support
+    # list.sort(key=) nor list.sort(reverse=) keyword arguments, so
+    # we must implement the functionality of those keyword arguments
+    # by hand instead of passing them to list.sort().
+    def sorted(iterable, cmp=None, key=None, reverse=False):
+        if key is not None:
+            result = [(key(x), x) for x in iterable]
+        else:
+            result = iterable[:]
+        if cmp is None:
+            # Pre-2.3 Python does not support list.sort(None).
+            result.sort()
+        else:
+            result.sort(cmp)
+        if key is not None:
+            result = [t1 for t0,t1 in result]
+        if reverse:
+            result.reverse()
+        return result
 
-try:
-    True
-except NameError:
-    # Pre-2.2 Python has no True keyword.
-    import __builtin__
-    __builtin__.True = not 0
+if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None:
+    # We can't apply the 'callable' fixer until the floor is 2.6, but the
+    # '-3' option to Python 2.6 and 2.7 generates almost ten thousand
+    # warnings.  This hack allows us to run regression tests with the '-3'
+    # option by replacing the callable() built-in function with a hack
+    # that performs the same function but doesn't generate the warning.
+    # Note that this hack is ONLY intended to be used for regression
+    # testing, and should NEVER be used for real runs.
+    from types import ClassType
+    def callable(obj):
+        if hasattr(obj, '__call__'): return True
+        if isinstance(obj, (ClassType, type)): return True
+        return False
 
 def make_temp_file(**kw):
     try:
@@ -79,7 +101,18 @@
             tempfile.template = save_template
     return result
 
-class Plotter:
+def HACK_for_exec(cmd, *args):
+    '''
+    For some reason, Python won't allow an exec() within a function
+    that also declares an internal function (including lambda functions).
+    This function is a hack that calls exec() in a function with no
+    internal functions.
+    '''
+    if not args:          exec(cmd)
+    elif len(args) == 1:  exec cmd in args[0]
+    else:                 exec cmd in args[0], args[1]
+
+class Plotter(object):
     def increment_size(self, largest):
         """
         Return the size of each horizontal increment line for a specified
@@ -87,12 +120,12 @@
         between 5 and 9 horizontal lines on the graph, on some set of
         boundaries that are multiples of 10/100/1000/etc.
         """
-        i = largest / 5
+        i = largest // 5
         if not i:
             return largest
         multiplier = 1
         while i >= 10:
-            i = i / 10
+            i = i // 10
             multiplier = multiplier * 10
         return i * multiplier
 
@@ -100,9 +133,9 @@
         # Round up to next integer.
         largest = int(largest) + 1
         increment = self.increment_size(largest)
-        return ((largest + increment - 1) / increment) * increment
+        return ((largest + increment - 1) // increment) * increment
 
-class Line:
+class Line(object):
     def __init__(self, points, type, title, label, comment, fmt="%s %s"):
         self.points = points
         self.type = type
@@ -166,13 +199,13 @@
         result = []
         for line in self.lines:
             result.extend(line.get_x_values())
-        return filter(lambda r: not r is None, result)
+        return [r for r in result if not r is None]
 
     def get_all_y_values(self):
         result = []
         for line in self.lines:
             result.extend(line.get_y_values())
-        return filter(lambda r: not r is None, result)
+        return [r for r in result if not r is None]
 
     def get_min_x(self):
         try:
@@ -225,10 +258,9 @@
 
         min_y = self.get_min_y()
         max_y = self.max_graph_value(self.get_max_y())
-        range = max_y - min_y
-        incr = range / 10.0
+        incr = (max_y - min_y) / 10.0
         start = min_y + (max_y / 2.0) + (2.0 * incr)
-        position = [ start - (i * incr) for i in xrange(5) ]
+        position = [ start - (i * incr) for i in range(5) ]
 
         inx = 1
         for line in self.lines:
@@ -263,12 +295,11 @@
         open(name, 'w').write(zf.read(name))
 
 def read_tree(dir):
-    def read_files(arg, dirname, fnames):
-        for fn in fnames:
-            fn = os.path.join(dirname, fn)
+    for dirpath, dirnames, filenames in os.walk(dir):
+        for fn in filenames:
+            fn = os.path.join(dirpath, fn)
             if os.path.isfile(fn):
                 open(fn, 'rb').read()
-    os.path.walk('.', read_files, None)
 
 def redirect_to_file(command, log):
     return '%s > %s 2>&1' % (command, log)
@@ -278,7 +309,7 @@
 
 
     
-class SConsTimer:
+class SConsTimer(object):
     """
     Usage: scons-time SUBCOMMAND [ARGUMENTS]
     Type "scons-time help SUBCOMMAND" for help on a specific subcommand.
@@ -495,9 +526,7 @@
         """
         files = []
         for a in args:
-            g = glob.glob(a)
-            g.sort()
-            files.extend(g)
+            files.extend(sorted(glob.glob(a)))
 
         if tail:
             files = files[-tail:]
@@ -528,7 +557,7 @@
 
         for file in files:
             base = os.path.splitext(file)[0]
-            run, index = string.split(base, '-')[-2:]
+            run, index = base.split('-')[-2:]
 
             run = int(run)
             index = int(index)
@@ -566,11 +595,11 @@
         and returns the next run number after the largest it finds.
         """
         x = re.compile(re.escape(prefix) + '-([0-9]+).*')
-        matches = map(lambda e, x=x: x.match(e), os.listdir(dir))
-        matches = filter(None, matches)
+        matches = [x.match(e) for e in os.listdir(dir)]
+        matches = [_f for _f in matches if _f]
         if not matches:
             return 0
-        run_numbers = map(lambda m: int(m.group(1)), matches)
+        run_numbers = [int(m.group(1)) for m in matches]
         return int(max(run_numbers)) + 1
 
     def gnuplot_results(self, results, fmt='%s %.3f'):
@@ -579,10 +608,7 @@
         """
         gp = Gnuplotter(self.title, self.key_location)
 
-        indices = results.keys()
-        indices.sort()
-
-        for i in indices:
+        for i in sorted(results.keys()):
             try:
                 t = self.run_titles[i]
             except IndexError:
@@ -704,7 +730,7 @@
         lines = open(file).readlines()
         line = [ l for l in lines if l.endswith(object_string) ][0]
         result = [ int(field) for field in line.split()[:4] ]
-        if not index is None:
+        if index is not None:
             result = result[index]
         return result
 
@@ -830,7 +856,7 @@
                 self.title = a
 
         if self.config_file:
-            execfile(self.config_file, self.__dict__)
+            exec open(self.config_file, 'rU').read() in self.__dict__
 
         if self.chdir:
             os.chdir(self.chdir)
@@ -859,19 +885,18 @@
 
         if format == 'ascii':
 
-            def print_function_timing(file, func):
+            for file in args:
                 try:
-                    f, line, func, time = self.get_function_profile(file, func)
+                    f, line, func, time = \
+                            self.get_function_profile(file, function_name)
                 except ValueError, e:
-                    sys.stderr.write("%s: func: %s: %s\n" % (self.name, file, e))
+                    sys.stderr.write("%s: func: %s: %s\n" %
+                                     (self.name, file, e))
                 else:
                     if f.startswith(cwd_):
                         f = f[len(cwd_):]
                     print "%.3f %s:%d(%s)" % (time, f, line, func)
 
-            for file in args:
-                print_function_timing(file, function_name)
-
         elif format == 'gnuplot':
 
             results = self.collect_results(args, self.get_function_time,
@@ -950,11 +975,11 @@
                 self.title = a
 
         if self.config_file:
-            execfile(self.config_file, self.__dict__)
+            HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
 
         if self.chdir:
             os.chdir(self.chdir)
-            logfile_path = lambda x, c=self.chdir: os.path.join(c, x)
+            logfile_path = lambda x: os.path.join(self.chdir, x)
 
         if not args:
 
@@ -1070,11 +1095,11 @@
         object_name = args.pop(0)
 
         if self.config_file:
-            execfile(self.config_file, self.__dict__)
+            HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
 
         if self.chdir:
             os.chdir(self.chdir)
-            logfile_path = lambda x, c=self.chdir: os.path.join(c, x)
+            logfile_path = lambda x: os.path.join(self.chdir, x)
 
         if not args:
 
@@ -1208,7 +1233,7 @@
             sys.exit(1)
 
         if self.config_file:
-            execfile(self.config_file, self.__dict__)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list