Package duplicity :: Module static
[hide private]
[frames] | no frames]

Source Code for Module duplicity.static

 1  # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- 
 2  # 
 3  # Copyright 2002 Ben Escoto <ben@emerose.org> 
 4  # Copyright 2007 Kenneth Loafman <kenneth@loafman.com> 
 5  # 
 6  # This file is part of duplicity. 
 7  # 
 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. 
12  # 
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. 
17  # 
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 
21   
22  """MakeStatic and MakeClass 
23   
24  These functions are used to make all the instance methods in a class 
25  into static or class methods. 
26   
27  """ 
28   
29 -class StaticMethodsError(Exception): pass
30
31 -def MakeStatic(cls):
32 """turn instance methods into static ones 33 34 The methods (that don't begin with _) of any class that 35 subclasses this will be turned into static methods. 36 37 """ 38 for name in dir(cls): 39 if name[0] != "_": 40 cls.__dict__[name] = staticmethod(cls.__dict__[name])
41
42 -def MakeClass(cls):
43 """Turn instance methods into classmethods. Ignore _ like above""" 44 for name in dir(cls): 45 if name[0] != "_": 46 cls.__dict__[name] = classmethod(cls.__dict__[name])
47