1
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
3
# Copyright 2002 Ben Escoto <ben@emerose.org>
4
# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
6
# This file is part of duplicity.
8
# Duplicity is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by the
10
# Free Software Foundation; either version 2 of the License, or (at your
11
# option) any later version.
13
# Duplicity is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with duplicity; if not, write to the Free Software Foundation,
20
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
"""MakeStatic and MakeClass
24
These functions are used to make all the instance methods in a class
25
into static or class methods.
29
class StaticMethodsError(Exception): pass
32
"""turn instance methods into static ones
34
The methods (that don't begin with _) of any class that
35
subclasses this will be turned into static methods.
40
cls.__dict__[name] = staticmethod(cls.__dict__[name])
43
"""Turn instance methods into classmethods. Ignore _ like above"""
46
cls.__dict__[name] = classmethod(cls.__dict__[name])