From cd5a1cb14bda6f9b42921832c883e2eeaa0dbead Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 16 Jan 2004 16:13:24 +0000 Subject: [PATCH] Added changeFunctionName to be used elsewhere. --- src/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils.py b/src/utils.py index 15c5f4d78..2f5a6e264 100755 --- a/src/utils.py +++ b/src/utils.py @@ -43,6 +43,7 @@ import os import re import md5 import sha +import types import string import sgmllib import compiler @@ -525,9 +526,17 @@ def nonEmptyLines(fd): def nonCommentNonEmptyLines(fd): return nonEmptyLines(nonCommentLines(fd)) +def changeFunctionName(f, name, doc=None): + if doc is None: + doc = f.__doc__ + newf = types.FunctionType(f.func_code, f.func_globals, name, + f.func_defaults, f.func_closure) + newf.__doc__ = doc + return newf if __name__ == '__main__': import sys, doctest doctest.testmod(sys.modules['__main__']) + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: