~ed.so/duplicity/manpage.verify

« back to all changes in this revision

Viewing changes to duplicity/static.py

  • Committer: Kenneth Loafman
  • Date: 2014-04-19 19:42:49 UTC
  • mfrom: (974.1.1 drop-static)
  • Revision ID: kenneth@loafman.com-20140419194249-6dv7bswyc6ihxe4h
* Merged in lp:~mterry/duplicity/drop-static
  - Drop static.py.
  - This is some of the oldest code in duplicity! A bzr blame says it is 
    unmodified (except for whitespace / comment changes) since revision 1.
  - But it's not needed anymore. Not really even since we updated to python2.4, 
    which introduced the @staticmethod decorator. So this branch drops it and 
    its test file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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])