X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fextensions.py;fp=daklib%2Fextensions.py;h=0000000000000000000000000000000000000000;hb=611ee43f7f1035c8b21bc8492bc92d74b8b4e7d2;hp=88de8700a9d16d2a5060c8623909bfc463b136c5;hpb=840d1649fce981ff93070826cba0fc268782f038;p=dak.git diff --git a/daklib/extensions.py b/daklib/extensions.py deleted file mode 100755 index 88de8700..00000000 --- a/daklib/extensions.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -""" -Utility functions for extensions - -@contact: Debian FTP Master -@copyright: 2008 Anthony Towns -@license: GNU General Public License version 2 or later -""" - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -dak_functions_to_replace = {} -dak_replaced_functions = {} - -def replace_dak_function(module, name): - """ - Decorator to make a function replace a standard dak function - in a given module. - - @type module: string - @param module: name of module where replaced function is in - - @type name: string - @param name: name of the function to replace - """ - - def x(f): - def myfunc(*a,**kw): - global replaced_funcs - f(dak_replaced_functions[name], *a, **kw) - myfunc.__name__ = f.__name__ - myfunc.__doc__ = f.__doc__ - myfunc.__dict__.update(f.__dict__) - - fnname = "%s:%s" % (module, name) - if fnname in dak_functions_to_replace: - raise Exception, \ - "%s in %s already marked to be replaced" % (name, module) - dak_functions_to_replace["%s:%s" % (module,name)] = myfunc - return f - return x - -################################################################################ - -def init(name, module, userext): - global dak_replaced_functions - - # This bit should be done automatically too - dak_replaced_functions = {} - for f,newfunc in dak_functions_to_replace.iteritems(): - m,f = f.split(":",1) - if len(f) > 0 and m == name: - dak_replaced_functions[f] = module.__dict__[f] - module.__dict__[f] = newfunc