1
# Copyright 2002 Ben Escoto
3
# This file is part of rdiff-backup.
5
# rdiff-backup is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA
8
# 02139, USA; either version 2 of the License, or (at your option) any
9
# later version; incorporated herein by reference.
11
"""MakeStatic and MakeClass
13
These functions are used to make all the instance methods in a class
14
into static or class methods.
18
class StaticMethodsError(Exception): pass
21
"""turn instance methods into static ones
23
The methods (that don't begin with _) of any class that
24
subclasses this will be turned into static methods.
29
cls.__dict__[name] = staticmethod(cls.__dict__[name])
32
"""Turn instance methods into classmethods. Ignore _ like above"""
35
cls.__dict__[name] = classmethod(cls.__dict__[name])