Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/profile.py

    r2 r388  
    33# Class for profiling python code. rev 1.0  6/2/94
    44#
     5# Written by James Roskind
    56# Based on prior profile module by Sjoerd Mullender...
    67#   which was hacked somewhat by: Guido van Rossum
     
    89"""Class for profiling Python code."""
    910
    10 # Copyright 1994, by InfoSeek Corporation, all rights reserved.
    11 # Written by James Roskind
     11# Copyright Disney Enterprises, Inc.  All Rights Reserved.
     12# Licensed to PSF under a Contributor Agreement
    1213#
    13 # Permission to use, copy, modify, and distribute this Python software
    14 # and its associated documentation for any purpose (subject to the
    15 # restriction in the following sentence) without fee is hereby granted,
    16 # provided that the above copyright notice appears in all copies, and
    17 # that both that copyright notice and this permission notice appear in
    18 # supporting documentation, and that the name of InfoSeek not be used in
    19 # advertising or publicity pertaining to distribution of the software
    20 # without specific, written prior permission.  This permission is
    21 # explicitly restricted to the copying and modification of the software
    22 # to remain in Python, compiled Python, or other languages (such as C)
    23 # wherein the modified or derived code is exclusively imported into a
    24 # Python module.
     14# Licensed under the Apache License, Version 2.0 (the "License");
     15# you may not use this file except in compliance with the License.
     16# You may obtain a copy of the License at
    2517#
    26 # INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
    27 # SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
    28 # FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY
    29 # SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
    30 # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
    31 # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
    32 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    33 
     18# http://www.apache.org/licenses/LICENSE-2.0
     19#
     20# Unless required by applicable law or agreed to in writing, software
     21# distributed under the License is distributed on an "AS IS" BASIS,
     22# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
     23# either express or implied.  See the License for the specific language
     24# governing permissions and limitations under the License.
    3425
    3526
     
    7667        return prof.print_stats(sort)
    7768
    78 def runctx(statement, globals, locals, filename=None):
     69def runctx(statement, globals, locals, filename=None, sort=-1):
    7970    """Run statement under profiler, supplying your own globals and locals,
    8071    optionally saving results in filename.
     
    9182        prof.dump_stats(filename)
    9283    else:
    93         return prof.print_stats()
     84        return prof.print_stats(sort)
    9485
    9586# Backwards compatibility.
     
    9788    print "Documentation for the profile module can be found "
    9889    print "in the Python Library Reference, section 'The Python Profiler'."
    99 
    100 if os.name == "mac":
    101     import MacOS
    102     def _get_time_mac(timer=MacOS.GetTicks):
    103         return timer() / 60.0
    10490
    10591if hasattr(os, "times"):
     
    179165                self.dispatcher = self.trace_dispatch
    180166                self.get_time = _get_time_resource
    181             elif os.name == 'mac':
    182                 self.timer = MacOS.GetTicks
    183                 self.dispatcher = self.trace_dispatch_mac
    184                 self.get_time = _get_time_mac
    185167            elif hasattr(time, 'clock'):
    186168                self.timer = self.get_time = time.clock
     
    599581        help="Save stats to <outfile>", default=None)
    600582    parser.add_option('-s', '--sort', dest="sort",
    601         help="Sort order when printing to stdout, based on pstats.Stats class", default=-1)
     583        help="Sort order when printing to stdout, based on pstats.Stats class",
     584        default=-1)
    602585
    603586    if not sys.argv[1:]:
     
    606589
    607590    (options, args) = parser.parse_args()
    608 
    609     if (len(args) > 0):
    610         sys.argv[:] = args
    611         sys.path.insert(0, os.path.dirname(sys.argv[0]))
    612         run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
     591    sys.argv[:] = args
     592
     593    if len(args) > 0:
     594        progname = args[0]
     595        sys.path.insert(0, os.path.dirname(progname))
     596        with open(progname, 'rb') as fp:
     597            code = compile(fp.read(), progname, 'exec')
     598        globs = {
     599            '__file__': progname,
     600            '__name__': '__main__',
     601            '__package__': None,
     602        }
     603        runctx(code, globs, None, options.outfile, options.sort)
    613604    else:
    614605        parser.print_usage()
Note: See TracChangeset for help on using the changeset viewer.