mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Added changeFunctionName to be used elsewhere.
This commit is contained in:
parent
8f53601882
commit
cd5a1cb14b
@ -43,6 +43,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import md5
|
import md5
|
||||||
import sha
|
import sha
|
||||||
|
import types
|
||||||
import string
|
import string
|
||||||
import sgmllib
|
import sgmllib
|
||||||
import compiler
|
import compiler
|
||||||
@ -525,9 +526,17 @@ def nonEmptyLines(fd):
|
|||||||
def nonCommentNonEmptyLines(fd):
|
def nonCommentNonEmptyLines(fd):
|
||||||
return nonEmptyLines(nonCommentLines(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__':
|
if __name__ == '__main__':
|
||||||
import sys, doctest
|
import sys, doctest
|
||||||
doctest.testmod(sys.modules['__main__'])
|
doctest.testmod(sys.modules['__main__'])
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user