/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/api.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 14:01:07 UTC
  • mto: This revision was merged to the branch mainline in revision 6680.
  • Revision ID: jelmer@jelmer.uk-20170610140107-man7tz8yv4czpyr1
Remove breezy.api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009, 2011 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
"""Library API versioning support.
18
 
 
19
 
Added in breezy 0.18 this allows export of compatibility information about
20
 
breezy. Please see doc/developers/api-versioning.txt for design details and
21
 
examples.
22
 
"""
23
 
 
24
 
from __future__ import absolute_import
25
 
 
26
 
import breezy
27
 
from .errors import IncompatibleAPI
28
 
 
29
 
 
30
 
def get_current_api_version():
31
 
    """Return the API version tuple for breezy.
32
 
 
33
 
    Added in breezy 0.18.
34
 
    """
35
 
    return breezy.version_info[0:3]
36
 
 
37
 
 
38
 
def require_api(wanted_api):
39
 
    """Check if breezy supports the api version wanted_api.
40
 
 
41
 
    :param wanted_api: The API version for which support is required.
42
 
    :return: None
43
 
    :raises IncompatibleAPI: When the wanted_api is not supported by
44
 
        breezy.
45
 
 
46
 
    Added in breezy 0.18.
47
 
    """
48
 
    current = get_current_api_version()
49
 
    if wanted_api != current:
50
 
        raise IncompatibleAPI(breezy, wanted_api, current)
51
 
 
52
 
 
53
 
def require_any_api(wanted_api_list):
54
 
    """Check if breezy supports the api version wanted_api.
55
 
 
56
 
    :param wanted_api: A list of API versions, any of which being available is
57
 
        sufficent.
58
 
    :return: None
59
 
    :raises IncompatibleAPI: When the wanted_api is not supported by
60
 
        breezy.
61
 
 
62
 
    Added in breezy 1.9.
63
 
    """
64
 
    current = get_current_api_version()
65
 
    if not current in wanted_api_list:
66
 
        raise IncompatibleAPI(breezy, wanted_api_list[-1], current)