/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-05-21 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Library API versioning support.
18
18
 
19
 
Added in brzlib 0.18 this allows export of compatibility information about
20
 
brzlib. Please see doc/developers/api-versioning.txt for design details and
 
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
21
examples.
22
22
"""
23
23
 
24
24
from __future__ import absolute_import
25
25
 
26
 
import brzlib
27
 
from brzlib.errors import IncompatibleAPI
 
26
import breezy
 
27
from breezy.errors import IncompatibleAPI
28
28
 
29
29
 
30
30
def get_current_api_version(object_with_api):
34
34
        object has a api_current_version attribute, that is used. Otherwise if
35
35
        there is a version_info attribute, its first three elements are used.
36
36
        Finally if there was no version_info attribute, the current api version
37
 
        of brzlib itself is used.
 
37
        of breezy itself is used.
38
38
 
39
 
    Added in brzlib 0.18.
 
39
    Added in breezy 0.18.
40
40
    """
41
41
    try:
42
42
        return object_with_api.api_current_version
44
44
        try:
45
45
            return object_with_api.version_info[0:3]
46
46
        except AttributeError:
47
 
            return get_current_api_version(brzlib)
 
47
            return get_current_api_version(breezy)
48
48
 
49
49
 
50
50
def get_minimum_api_version(object_with_api):
52
52
 
53
53
    :param object_with_api: An object to look for an API version on. If the
54
54
        object has a api_minimum_version attribute, that is used. Otherwise the
55
 
        minimum api version of brzlib itself is used.
 
55
        minimum api version of breezy itself is used.
56
56
 
57
 
    Added in brzlib 0.18.
 
57
    Added in breezy 0.18.
58
58
    """
59
59
    try:
60
60
        return object_with_api.api_minimum_version
61
61
    except AttributeError:
62
 
        return get_minimum_api_version(brzlib)
 
62
        return get_minimum_api_version(breezy)
63
63
 
64
64
 
65
65
def require_api(object_with_api, wanted_api):
73
73
    :raises IncompatibleAPI: When the wanted_api is not supported by
74
74
        object_with_api.
75
75
 
76
 
    Added in brzlib 0.18.
 
76
    Added in breezy 0.18.
77
77
    """
78
78
    current = get_current_api_version(object_with_api)
79
79
    minimum = get_minimum_api_version(object_with_api)
93
93
    :raises IncompatibleAPI: When the wanted_api is not supported by
94
94
        object_with_api.
95
95
 
96
 
    Added in brzlib 1.9.
 
96
    Added in breezy 1.9.
97
97
    """
98
98
    for api in wanted_api_list[:-1]:
99
99
        try: