8000 Move the constants at the gitlab root level · mishin/python-gitlab@2ced9d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ced9d0

Browse files
author
Gauvain Pocentek
committed
Move the constants at the gitlab root level
1 parent 23b2a30 commit 2ced9d0

File tree

5 files changed

+47
-20
lines changed

5 files changed

+47
-20
lines changed

docs/gl_objects/groups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545

4646
# member create
4747
member = gl.group_members.create({'user_id': user_id,
48-
'access_level': Group.GUEST_ACCESS},
48+
'access_level': gitlab.GUEST_ACCESS},
4949
group_id=1)
5050
# or
5151
member = group.members.create({'user_id': user_id,
52-
'access_level': Group.GUEST_ACCESS})
52+
'access_level': gitlab.GUEST_ACCESS})
5353
# end member create
5454

5555
# member update
56-
member.access_level = Group.DEVELOPER_ACCESS
56+
member.access_level = gitlab.DEVELOPER_ACCESS
5757
member.save()
5858
# end member update
5959

docs/gl_objects/projects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@
9494

9595
# members add
9696
member = gl.project_members.create({'user_id': user.id, 'access_level':
97-
gitlab.Group.DEVELOPER_ACCESS},
97+
gitlab.DEVELOPER_ACCESS},
9898
project_id=1)
9999
# or
100100
member = project.members.create({'user_id': user.id, 'access_level':
101-
gitlab.Group.DEVELOPER_ACCESS})
101+
gitlab.DEVELOPER_ACCESS})
102102
# end members add
103103

104104
# members update
105-
member.access_level = gitlab.Group.MASTER_ACCESS
105+
member.access_level = gitlab.MASTER_ACCESS
106106
member.save()
107107
# end members update
108108

@@ -115,7 +115,7 @@
115115
# end members delete
116116

117117
# share
118-
project.share(group.id, group.DEVELOPER_ACCESS)
118+
project.share(group.id, gitlab.DEVELOPER_ACCESS)
119119
# end share
120120

121121
# hook list
@@ -291,14 +291,14 @@
291291
'file_name': 'foo.py',
292292
'code': 'import gitlab',
293293
'visibility_level':
294-
Project.VISIBILITY_PRIVATE},
294+
gitlab.VISIBILITY_PRIVATE},
295295
project_id=1)
296296
# or
297297
snippet = project.snippets.create({'title': 'sample 1',
298298
'file_name': 'foo.py',
299299
'code': 'import gitlab',
300300
'visibility_level':
301-
Project.VISIBILITY_PRIVATE})
301+
gitlab.VISIBILITY_PRIVATE})
302302
# end snippets create
303303

304304
# snippets content

gitlab/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import six
2929

3030
import gitlab.config
31+
from gitlab.const import * # noqa
3132
from gitlab.exceptions import * # noqa
3233
from gitlab.objects import * # noqa
3334

gitlab/const.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2016 Gauvain Pocentek <gauvain@pocentek.net>
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU Lesser General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
GUEST_ACCESS = 10
19+
REPORTER_ACCESS = 20
20+
DEVELOPER_ACCESS = 30
21+
MASTER_ACCESS = 40
22+
OWNER_ACCESS = 50
23+
24+
VISIBILITY_PRIVATE = 0
25+
VISIBILITY_INTERNAL = 10
26+
VISIBILITY_PUBLIC = 20

gitlab/objects.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -795,15 +795,15 @@ class Group(GitlabObject):
795795
('projects', GroupProjectManager, [('group_id', 'id')]),
796796
('issues', GroupIssueManager, [('group_id', 'id')])]
797797

798-
GUEST_ACCESS = 10
799-
REPORTER_ACCESS = 20
800-
DEVELOPER_ACCESS = 30
801-
MASTER_ACCESS = 40
802-
OWNER_ACCESS = 50
798+
GUEST_ACCESS = gitlab.GUEST_ACCESS
799+
REPORTER_ACCESS = gitlab.REPORTER_ACCESS
800+
DEVELOPER_ACCESS = gitlab.DEVELOPER_ACCESS
801+
MASTER_ACCESS = gitlab.MASTER_ACCESS
802+
OWNER_ACCESS = gitlab.OWNER_ACCESS
803803

804-
VISIBILITY_PRIVATE = 0
805-
VISIBILITY_INTERNAL = 10
806-
VISIBILITY_PUBLIC = 20
804+
VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE
805+
VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL
806+
VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC
807807

808808
def Member(self, id=None, **kwargs):
809809
warnings.warn("`Member` is deprecated, use `members` instead",
@@ -1787,9 +1787,9 @@ class Project(GitlabObject):
17871787
('variables', ProjectVariableManager, [('project_id', 'id')]),
17881788
]
17891789

1790-
VISIBILITY_PRIVATE = 0
1791-
VISIBILITY_INTERNAL = 10
1792-
VISIBILITY_PUBLIC = 20
1790+
VISIBILITY_PRIVATE = gitlab.VISIBILITY_PRIVATE
1791+
VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL
1792+
VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC
17931793

17941794
def Branch(self, id=None, **kwargs):
17951795
warnings.warn("`Branch` is deprecated, use `branches` instead",

0 commit comments

Comments
 (0)
0