summaryrefslogtreecommitdiff
path: root/soledad/src/leap/soledad/backends/leap_backend.py
blob: a8d76b673c6f666b1b6b12cc10a511b2b8590f45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
# leap_backend.py 
# Copyright (C) 2013 LEAP
#
# 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 3 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, see <http://www.gnu.org/licenses/>.


"""
This file exists to provide backwards compatibility with code that uses
Soledad before the refactor that removed the leap_backend module.
"""


import logging
import warnings


from leap.soledad import document
from leap.soledad import target


logger = logging.getLogger(name=__name__)


def warn(oldclass, newclass):
    """
    Warns about deprecation of C{oldclass}, which must be substituted by
    C{newclass}.

    @param oldclass: The class that is deprecated.
    @type oldclass: type
    @param newclass: The class that should be used instead.
    @type newclass: type
    """
    message = \
        "%s is deprecated and will be removed soon. Please use %s instead." \
        % (str(oldclass), str(newclass))
    print message
    logger.warning(message)
    warnings.warn(message, DeprecationWarning, stacklevel=2)


class LeapDocument(document.SoledadDocument):
    """
    This class exists to provide backwards compatibility with code that still
    uses C{leap.soledad.backends.leap_backend.LeapDocument}.
    """

    def __init__(self, *args, **kwargs):
        warn(self.__class__, document.SoledadDocument)
        document.SoledadDocument.__init__(self, *args, **kwargs)


class EncryptionSchemes(target.EncryptionSchemes):
    """
    This class exists to provide backwards compatibility with code that still
    uses C{leap.soledad.backends.leap_backend.EncryptionSchemes}.
    """

    def __init__(self, *args, **kwargs):
        warn(self.__class__, target.EncryptionSchemes)
        target.EncryptionSchemes.__init__(self, *args, **kwargs)